Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // указать api key, номер метрики вместо 99999999 и сохранить как скрипт с именем: metrika.php
- // на сайт подключить кодом: <script defer src="/metrika.php"></script>
- $apikey = ''; // API Key с сайта ipscore.biz
- // определение IP адреса (совместим с cloudflare):
- if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
- $ip = strip_tags($_SERVER['HTTP_CF_CONNECTING_IP']);
- } else {
- $ip = isset($_SERVER['REMOTE_ADDR']) ? strip_tags($_SERVER['REMOTE_ADDR']) : die('// IP');
- }
- // код метрики:
- $metrika = '(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
- m[i].l=1*new Date();
- for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
- k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
- (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
- ym(99999999, "init", {
- clickmap:true,
- trackLinks:true,
- accurateTrackBounce:true,
- webvisor:true,
- params:{"ip": "'.$ip.'"}
- });';
- // дальше не нужно ничего менять:
- header('Content-Type: text/javascript; charset=UTF-8');
- header('Expires: Thu, 18 Aug 1994 05:00:00 GMT');
- header('Cache-Control: no-store, no-cache, must-revalidate');
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://ipscore.biz/api/'.$apikey.'/'.$ip.'/score.json');
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 600);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
- curl_setopt($ch, CURLOPT_USERAGENT, 'ipscoreclient'); // не изменять user-agent!
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
- curl_setopt($ch, CURLOPT_FTP_SSL, CURLFTPSSL_TRY);
- $outch = curl_exec($ch);
- curl_close($ch);
- $outch = json_decode($outch, true);
- if (isset($outch['score']) AND $outch['score'] == 1) {echo $metrika;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement