유입로그 저장 또는 검색엔진 키워드 찾기
페이지 정보
작성자 최고관리자 작성일 21-02-09 11:57 조회 8,051 댓글 0본문
########################################################################################################
# 유입로그 저장 또는 검색엔진 키워드 찾기 네이버 키워드 찾기
# 매달 테이블 만듦
########################################################################################################
include ("connect.php");
$connect = db_connect("DBname");
$toYm = date("Ym");
$tbname = "inputlog_" . $toYm;
$chsql = "SHOW TABLES LIKE '$tbname'";
$chresult = mysql_query($chsql);
$chrow = mysql_fetch_array($chresult);
if(!$chrow[0])
{
$creatsql = " CREATE TABLE IF NOT EXISTS `{$tbname}` (";
$creatsql .= " `no` int(8) NOT NULL auto_increment,";
$creatsql .= " `writeday` varchar(30) NOT NULL default '',";
$creatsql .= " `ip` varchar(30) default NULL,";
$creatsql .= " `domain_name` varchar(50) default NULL,";
$creatsql .= " `ref` text,";
$creatsql .= " `keyword` varchar(30) default NULL,";
$creatsql .= " `macadd` varchar(13) default NULL,";
$creatsql .= " `surl` text,";
$creatsql .= " PRIMARY KEY (`no`),";
$creatsql .= " KEY `ip` (`ip`))";
$creatresult = mysql_query($creatsql);
}
$ip = $_SERVER['REMOTE_ADDR'];
$servername = $_SERVER['SERVER_NAME'];
$ref = $_SERVER['HTTP_REFERER'];
$surl = "http://$servername" . $_SERVER['REQUEST_URI'];
$useragnet = $_SERVER['HTTP_USER_AGENT'];
$qSTRING = $_SERVER['QUERY_STRING'];
$http_host = $_SERVER['HTTP_HOST'];
// 검색엔진 키워드 찾기
if($ref)
{
if(eregi("search.yahoo", "$ref")){$separator = "p=";}
else if(eregi("naver.com", "$ref")){$separator = "query=";}
else if(eregi("hanafos.com", "$ref")){$separator = "keyword=";}
else if(eregi("paran.com", "$ref")){$separator = "KeyWord=";}
else if(eregi("gajai.com", "$ref")){$separator = "keyword=";}
else if(eregi("hajai.com", "$ref")){$separator = "p=";}
else if(eregi("tongsearch.nate.com", "$ref")){$separator = "query="; }
else if(eregi("askpop.com", "$ref")){$separator = "keywordstr="; }
else {$separator = "q=";}
$agent1 = explode($separator,$ref);
$agent2 = explode("&", $agent1[1]);
$Squery = strtolower($agent2[0]);
//$Squery = urldecode($Squery);
}
// 네이버 키워드 변환 //
$a = rawurldecode($Squery);
$naverKeyword = iconv('UTF-8', 'EUC-KR', $a);
if(!$naverKeyword) { $naverKeyword = $a; }
$sql = "insert into {$tbname} set writeday=now(), ip='$ip', domain_name='$servernam', ref='$ref', surl='$surl', keyword = '$Squery'";
$result = mysql_query($sql);
//$input_id = mysql_insert_id();
########################################################################
# 검색엔진 검색 키워드 추출
# pclab 2016.05.
########################################################################
function searchkeywordval ($param,$chek)
{
$temp = explode("?",$param);
$temparam = explode("&",$temp[1]);
for($zz=0;$zz<sizeof($temparam);$zz++)
{
$temval = explode("=",$temparam[$zz]);
if($temval[0] == $chek)
{
return $temval[1];
exit;
}
}
}
function searchkeyword($ref)
{
$reval = '';
if(preg_match("/naver.com/", strtolower("$ref"))){
$searchkey = searchkeywordval ($ref,"query");
$reval['searengine'] = "네이버";
}else if(preg_match("/daum.net\/nate/", strtolower("$ref"))){
$searchkey = searchkeywordval ($ref,"q");
$reval['searengine'] = "네이트";
}else if(preg_match("/daum.net\/search/", strtolower("$ref"))){
$searchkey = searchkeywordval ($ref,"q");
$reval['searengine'] = "다음";
}
if(preg_match("/\/\/m./", strtolower("$ref"))){
$reval['searengine'] .= " 모바일";
}
if($searchkey != ''){
$tmpreval = iconv('UTF-8','EUC-KR',rawurldecode($searchkey));
$reval['keyword'] = str_replace('+',' ',$tmpreval);
}
return $reval;
}
echo searchkeyword($ref);
# 유입로그 저장 또는 검색엔진 키워드 찾기 네이버 키워드 찾기
# 매달 테이블 만듦
########################################################################################################
include ("connect.php");
$connect = db_connect("DBname");
$toYm = date("Ym");
$tbname = "inputlog_" . $toYm;
$chsql = "SHOW TABLES LIKE '$tbname'";
$chresult = mysql_query($chsql);
$chrow = mysql_fetch_array($chresult);
if(!$chrow[0])
{
$creatsql = " CREATE TABLE IF NOT EXISTS `{$tbname}` (";
$creatsql .= " `no` int(8) NOT NULL auto_increment,";
$creatsql .= " `writeday` varchar(30) NOT NULL default '',";
$creatsql .= " `ip` varchar(30) default NULL,";
$creatsql .= " `domain_name` varchar(50) default NULL,";
$creatsql .= " `ref` text,";
$creatsql .= " `keyword` varchar(30) default NULL,";
$creatsql .= " `macadd` varchar(13) default NULL,";
$creatsql .= " `surl` text,";
$creatsql .= " PRIMARY KEY (`no`),";
$creatsql .= " KEY `ip` (`ip`))";
$creatresult = mysql_query($creatsql);
}
$ip = $_SERVER['REMOTE_ADDR'];
$servername = $_SERVER['SERVER_NAME'];
$ref = $_SERVER['HTTP_REFERER'];
$surl = "http://$servername" . $_SERVER['REQUEST_URI'];
$useragnet = $_SERVER['HTTP_USER_AGENT'];
$qSTRING = $_SERVER['QUERY_STRING'];
$http_host = $_SERVER['HTTP_HOST'];
// 검색엔진 키워드 찾기
if($ref)
{
if(eregi("search.yahoo", "$ref")){$separator = "p=";}
else if(eregi("naver.com", "$ref")){$separator = "query=";}
else if(eregi("hanafos.com", "$ref")){$separator = "keyword=";}
else if(eregi("paran.com", "$ref")){$separator = "KeyWord=";}
else if(eregi("gajai.com", "$ref")){$separator = "keyword=";}
else if(eregi("hajai.com", "$ref")){$separator = "p=";}
else if(eregi("tongsearch.nate.com", "$ref")){$separator = "query="; }
else if(eregi("askpop.com", "$ref")){$separator = "keywordstr="; }
else {$separator = "q=";}
$agent1 = explode($separator,$ref);
$agent2 = explode("&", $agent1[1]);
$Squery = strtolower($agent2[0]);
//$Squery = urldecode($Squery);
}
// 네이버 키워드 변환 //
$a = rawurldecode($Squery);
$naverKeyword = iconv('UTF-8', 'EUC-KR', $a);
if(!$naverKeyword) { $naverKeyword = $a; }
$sql = "insert into {$tbname} set writeday=now(), ip='$ip', domain_name='$servernam', ref='$ref', surl='$surl', keyword = '$Squery'";
$result = mysql_query($sql);
//$input_id = mysql_insert_id();
########################################################################
# 검색엔진 검색 키워드 추출
# pclab 2016.05.
########################################################################
function searchkeywordval ($param,$chek)
{
$temp = explode("?",$param);
$temparam = explode("&",$temp[1]);
for($zz=0;$zz<sizeof($temparam);$zz++)
{
$temval = explode("=",$temparam[$zz]);
if($temval[0] == $chek)
{
return $temval[1];
exit;
}
}
}
function searchkeyword($ref)
{
$reval = '';
if(preg_match("/naver.com/", strtolower("$ref"))){
$searchkey = searchkeywordval ($ref,"query");
$reval['searengine'] = "네이버";
}else if(preg_match("/daum.net\/nate/", strtolower("$ref"))){
$searchkey = searchkeywordval ($ref,"q");
$reval['searengine'] = "네이트";
}else if(preg_match("/daum.net\/search/", strtolower("$ref"))){
$searchkey = searchkeywordval ($ref,"q");
$reval['searengine'] = "다음";
}
if(preg_match("/\/\/m./", strtolower("$ref"))){
$reval['searengine'] .= " 모바일";
}
if($searchkey != ''){
$tmpreval = iconv('UTF-8','EUC-KR',rawurldecode($searchkey));
$reval['keyword'] = str_replace('+',' ',$tmpreval);
}
return $reval;
}
echo searchkeyword($ref);
댓글목록 0
등록된 댓글이 없습니다.