Guest User

Untitled

a guest
Apr 12th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.66 KB | None | 0 0
  1. <?php
  2.     function getKeywords()  
  3.     {  
  4.         $refer = parse_url($_SERVER['HTTP_REFERER']);  
  5.         $host = $refer['host'];  
  6.         $refer = $refer['query'];  
  7.          
  8.         if(strstr($host,'google'))  
  9.         {  
  10.             //do google stuff  
  11.             $match = preg_match('/&q=([a-zA-Z0-9+-]+)/',$refer, $output);  
  12.             $querystring = $output[0];  
  13.             $querystring = str_replace('&q=','',$querystring);  
  14.             $keywords = explode('+',$querystring);  
  15.             return $keywords;  
  16.         }  
  17.         elseif(strstr($host,'yahoo'))  
  18.         {  
  19.             //do yahoo stuff  
  20.             $match = preg_match('/p=([a-zA-Z0-9+-]+)/',$refer, $output);  
  21.             $querystring = $output[0];  
  22.             $querystring = str_replace('p=','',$querystring);  
  23.             $keywords = explode('+',$querystring);  
  24.             return $keywords;  
  25.              
  26.         }  
  27.         elseif(strstr($host,'msn'))  
  28.         {  
  29.             //do msn stuff  
  30.             $match = preg_match('/q=([a-zA-Z0-9+-]+)/',$refer, $output);  
  31.             $querystring = $output[0];  
  32.             $querystring = str_replace('q=','',$querystring);  
  33.             $keywords = explode('+',$querystring);  
  34.             return $keywords;  
  35.         }  
  36.         else  
  37.         {  
  38.             //else, who cares  
  39.             return false;  
  40.         }  
  41.     }  
  42.  
  43.     $refer = parse_url($_SERVER['HTTP_REFERER']);  
  44.     $host = $refer['host'];  
  45.      
  46.     if(strstr($host,'google') or strstr($host,'yahoo') or strstr($host,'msn') or strstr($host,'bing'))  
  47.     {  
  48.        
  49.             // Данные для mysql сервера
  50.             $dbhost = "sape.mysql.ukraine.com.ua"; // Хост
  51.             $dbuser = "sape_allsitesinf"; // Имя пользователя
  52.             $dbpassword = "4wjh77bp"; // Пароль
  53.             $dbname = "sape_allsitesinf"; // Имя базы данных
  54.  
  55.             // Подключаемся к mysql серверу
  56.             $link = mysql_connect($dbhost, $dbuser, $dbpassword);
  57.             // Выбираем нашу базу данных
  58.             mysql_select_db($dbname, $link);
  59.  
  60.             // Добавляем запись в нашу таблицу
  61.             // т.е. делаем sql запрос
  62.             $q = getKeywords();
  63.             $comma_separated = implode(",", $q);
  64.             $Ref_url = $_SERVER['HTTP_REFERER'];
  65.             $lang = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2));
  66.  
  67.             $datex = date("l dS Y h:I:s A");
  68.             $url = $_SERVER['HTTP_HOST'];
  69.  
  70.             $query = "insert into Keywords values('$Ref_url','$lang','$datex','$url','$comma_separated')";
  71.             echo $datex;
  72.             mysql_query($query, $link);
  73.  
  74.             // Закрываем соединение
  75.             mysql_close($link);
  76.     }  
  77.    
  78. ?>
Add Comment
Please, Sign In to add comment