$data = array();
$data['remote_ip'] = mb_substr( $this->_determine_remote_ip(), 0, 15 );
// check whether to ignore this hit
foreach ( $this->config->ignored_ips as $ip ) {
if ( mb_strpos( $data['remote_ip'], $ip ) === 0 ) {
return;
}
}
$data['referrer'] = ( isset( $_SERVER['HTTP_REFERER'] ) ) ? $_SERVER['HTTP_REFERER'] : '';
$url = parse_url( $data['referrer'] );
$data['referrer'] = mb_substr( SlimStat::utf8_encode( $data['referrer'] ), 0, 255 );
$data['country'] = $this->_determine_country( $data['remote_ip'] ); // always 2 chars, no need to truncate
$data['language'] = mb_substr( SlimStat::determine_language(), 0, 255 );
$data['domain'] = ( isset( $url['host'] ) ) ? mb_eregi_replace( '^www.', '', $url['host'] ) : '';
$data['domain'] = mb_substr( $data['domain'], 0, 255 );
$data['search_terms'] = mb_substr( SlimStat::utf8_encode( $this->_determine_search_terms( $url ) ), 0, 255 );
$data['resolution'] = '';
if ( array_key_exists( 'slimstat_resolution', $GLOBALS ) ) {
$data['resolution'] = mb_substr( $GLOBALS['slimstat_resolution'], 0, 10 );
}
$data['title'] = '';
if ( array_key_exists( 'slimstat_title', $GLOBALS ) ) {
$data['title'] = mb_substr( SlimStat::utf8_encode( $GLOBALS['slimstat_title'] ), 0, 255 );
}
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
$data['resource'] = $_SERVER['REQUEST_URI'];
} elseif ( isset( $_SERVER['SCRIPT_NAME'] ) && isset( $_SERVER['QUERY_STRING'] ) ) {
$data['resource'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
} elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
$data['resource'] = $_SERVER['SCRIPT_NAME'];
} elseif ( isset( $_SERVER['PHP_SELF'] ) && isset( $_SERVER['QUERY_STRING'] ) ) {
$data['resource'] = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
} elseif ( isset( $_SERVER['PHP_SELF'] ) ) {
$data['resource'] = $_SERVER['PHP_SELF'];
} else {
$data['resource'] = '';
}
$data['resource'] = mb_substr( SlimStat::utf8_encode( $data['resource'] ), 0, 255 );
$browser = $this->_parse_user_agent( $_SERVER['HTTP_USER_AGENT'] );
$data['platform'] = mb_substr( $browser['platform'], 0, 50 );
$data['browser'] = mb_substr( $browser['browser'], 0, 50 );
$data['version'] = mb_substr( SlimStat::parse_version( $browser['version'] ), 0, 15 );
// check whether to ignore this hit
if ( $data['browser'] == 'Crawler' && $this->config->log_crawlers == false ) {
return;
}
$ts = time();
$time = array(
'mi' => floor( gmdate( 'i', $ts ) / 15 ) * 15,
'hr' => gmdate( 'H', $ts ),
'dy' => gmdate( 'j', $ts ),
'mo' => gmdate( 'n', $ts ),
'yr' => gmdate( 'Y', $ts )
);