데이터는 필요사항에 맞춰 가공을 해야 편합니다.
//사용자OS function getOsName($agent) { global $OsSet1,$OsSet2; $i = 0; foreach($OsSet1 as $o) { $i++; if(strstr($agent,$o)) { if(is_array($OsSet2)) return $OsSet2[$i-1]; else return $i-1; } } return is_array($OsSet2) ? $OsSet2[0] : 0; } //사용자브라우저 function getBrowserName($agent) { global $BrSet1; $i = 0; foreach($BrSet1 as $b) { $i++; if (strstr($agent,$b)) return $i-1; } return 0; } //로봇 체크 function robotChecker($useragent) { $robotPattern = array( 'Googlebot' => 1, 'NaverBot' => 1, 'TechnoratiSnoop' => 1, 'Allblog.net' => 1, 'CazoodleBot' => 1, 'nhn/1noon' => 1, 'Feedfetcher-Google' => 1, 'Yahoo! Slurp' => 1, 'RMOM' => 1, 'msnbot' => 1, 'Technoratibot' => 1, 'sproose' => 1, 'CazoodleBot' => 1, 'ONNET-OPENAPI' => 1, 'UCLA CS Dept' => 1, 'Snapbot' => 1, 'DAUM RSS Robot' => 1, 'RMOM' => 1, 'S20 Wing' => 1, 'FeedBurner' => 1, 'xMind' => 1, 'openmaru feed aggregator' => 1, 'ColFeed' => 1, 'MJ12bot' => 1, 'Twiceler' => 1, 'ia_archiver' => 1, //'Daumoa' => 1, 'Mediapartners-Google' => 1 ); foreach ($robotPattern as $agentName => $value) if(strpos($useragent,$value)!==false) return true; return false; } //IP출력 function getIpAddress($ip,$flag,$es) { if (!$flag) return ''; if ($flag == 2) return $ip; else{ $ipx = explode('.' , $ip); $ips = $ipx[0].'.'.$ipx[1].'.'.$es.'.'.$ipx[3]; return $ips; } } // 실시간 접속 현황 세션 저장 $gnum = 0; $mbrstr = ''; $gststr = ''; $isRobot = robotChecker($_SERVER['HTTP_USER_AGENT']);//strstr($_SERVER['HTTP_USER_AGENT'],'bot'); $nowtime = $date['totime']; $country = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); $tmpfolder = './_tmp/guest/'; $now_path = urldecode(stripslashes($g['location'])); <- 각 사이트별 네비게이션 $OsSet1 = array('Unknown','Linux','Mac','Irix','Sunos','Phone','Windows CE','Windows 98','Windows 9','Windows NT 4','Windows NT 5.0','Windows NT 5.1','Windows NT 5.2','Windows NT 6.0','Windows NT 6.1','Windows NT 6.2','Windows NT 6.3'); $OsSet2 = array('Unknown','Linux','Mac','Irix','Sunos','Phone','Win CE','Win 98','Win ME','Win NT','Win 2000','Win XP','Win 2003','Vista','Win 7','Win 8','Win 8.1'); $BrSet1 = array('Unknown','MSIE 10','MSIE 9','MSIE 8','MSIE 7','MSIE 6','MSIE 5','Firefox','Opera','Chrome','Safari','Googlebot','bot','X11','Netscape','Swing'); $fp = fopen($tmpfolder.$_SERVER['REMOTE_ADDR'].'.guest', "w"); fwrite($fp , $nowtime.'|'.($_SESSION['logtime']?$_SESSION['logtime']:$nowtime).'|'.$now_path.'|'.$country.'|||'.$_SERVER['HTTP_USER_AGENT'].'||'.getOsName($_SERVER['HTTP_USER_AGENT']).'|'); fclose($fp); @chmod($tmpfolder.$_SERVER['REMOTE_ADDR'].'.guest',0707); if (!$isRobot) { $opendir = opendir($tmpfolder); while(false !== ($file = readdir($opendir))) { if($file == '.'|| $file == '..') continue; $timex = file($tmpfolder.$file); $time = explode('|',$timex[0]); $dtime = date('YmdHis', mktime(substr($time[0],8,2),substr($time[0],10,2)+3,substr($time[0],12,2),substr($time[0],4,2),substr($time[0],6,2),substr($time[0],0,4))); $ismember = strstr($file,'.member'); if($nowtime > $dtime) //파일 생성시간 3분 { unlink($tmpfolder.$file); } else { $gnum++; $gststr .= getIpAddress(str_replace('.guest','',$file),1,iconv("EUC-KR", "UTF-8", "★")).'^^^'.$time[1].'^'.$time[2].'^'.$time[3].'^^'.str_replace("^","",$time[6]).'^'.$time[7].'^'.$time[8].'^(@)'; } } closedir($opendir); }
'Dev Language > PHP' 카테고리의 다른 글
PHP에서 암호화 encrypt 복호화 decrypt 해서 값을 넘기기 (0) | 2015.06.18 |
---|---|
PHP ZIP 압축 라이브러리 (0) | 2015.06.03 |
PHP 문자열 인코딩 utf8,euc-kr 펑션 (0) | 2015.06.02 |
PHP 메일 보내기 (0) | 2015.06.02 |
PHP 배열 사용 (0) | 2015.06.02 |