Location: PHPKode > scripts > Nudalytics > nudalytics/core/realtime.php
<?php
//####################################################
//リアルタイム計測
//####################################################
function Nudalytics_realtime() {
	global $wpdb;
	$tablename = $wpdb->prefix.'Nudalytics';
?>
<div class="wrap">
<h2><?php _e("Realtime", "Nudalytics"); ?></h2>
<h3>Visitor List</h3>
<ul class="nt h">
	<li class="w10"><?php _e('Date', 'Nudalytics'); ?></li>
	<li class="w18"><?php _e('IP address / Host', 'Nudalytics'); ?></li>
	<li class="w30"><?php _e('URL', 'Nudalytics'); ?></li>
	<li class="w5"><?php _e('OS', 'Nudalytics'); ?></li>
	<li class="w5"><?php _e('Browser', 'Nudalytics'); ?></li>
	<li class="w30"><?php _e('Referrer', 'Nudalytics'); ?></li>
</ul>
<?php
	if(get_option('Nudalytics_numlog') != null)
		$list = $wpdb->get_results("SELECT * FROM $tablename WHERE NOT url like '%wp-admin%' AND NOT url like '%wp-content%' AND Crawler = ' ' order by Time desc limit 0, ".get_option('Nudalytics_numlog').";");
	else
		$list = $wpdb->get_results("SELECT * FROM $tablename WHERE NOT url like '%wp-admin%' AND NOT url like '%wp-content%' AND Crawler = ' ' order by Time desc limit 0, 50;");
	
	foreach ($list as $data) {
		if($data->SearchQuery != null)
			echo '<ul class="nt">'.
					'<li class="w10">'.$data->Time.'</li>'.
					'<li class="w18 sf">'.$data->IP.'<br />'.$data->Host.'</li>'.
					'<li class="w30">'.urldecode($data->URL).'</li>'.
					'<li class="w5 sf">'.$data->OS.'</li>'.
					'<li class="w5 sf">'.$data->Browser.'</li>'.
					'<li class="w30"><span class="b">'.$data->SearchEngine.'</span>: '.$data->SearchQuery.'</li>'.
					'</ul>';
		else {
			$urlstr = explode("/", $data->Referrer);
			if($urlstr[2] == $_SERVER['SERVER_NAME'])
				echo '<ul class="nt">'.
					'<li class="w10">'.$data->Time.'</li>'.
					'<li class="w18 sf">'.$data->IP.'<br />'.$data->Host.'</li>'.
					'<li class="w30">'.urldecode($data->URL).'</li>'.
					'<li class="w5 sf">'.$data->OS.'</li>'.
					'<li class="w5 sf">'.$data->Browser.'</li>'.
					'<li class="w30 g">'.urldecode($data->Referrer).'</li>'.
					'</ul>';
			elseif(strpos($data->Referrer, ".php")>=1 || strlen($urlstr[3])<=0)
				echo '<ul class="nt">'.
					'<li class="w10">'.$data->Time.'</li>'.
					'<li class="w18 sf">'.$data->IP.'<br />'.$data->Host.'</li>'.
					'<li class="w30">'.urldecode($data->URL).'</li>'.
					'<li class="w5 sf">'.$data->OS.'</li>'.
					'<li class="w5 sf">'.$data->Browser.'</li>'.
					'<li class="w30 r">'.urldecode($data->Referrer).'</li>'.
					'</ul>';
			else
				echo '<ul class="nt">'.
					'<li class="w10">'.$data->Time.'</li>'.
					'<li class="w18 sf">'.$data->IP.'<br />'.$data->Host.'</li>'.
					'<li class="w30">'.urldecode($data->URL).'</li>'.
					'<li class="w5 sf">'.$data->OS.'</li>'.
					'<li class="w5 sf">'.$data->Browser.'</li>'.
					'<li class="w30">'.urldecode($data->Referrer).'</li>'.
					'</ul>';
		}
	}
?>

<h3>Crawler List</h3>
<ul class="nt h">
	<li class="w20"><?php _e('Date', 'Nudalytics'); ?></li>
	<li class="w20"><?php _e('Crawler name', 'Nudalytics'); ?></li>
	<li class="w55"><?php _e('URL', 'Nudalytics'); ?></li>
</ul>
<?php
	if(get_option('Nudalytics_numlog') != null)
		$list = $wpdb->get_results("SELECT * FROM $tablename WHERE Crawler != ' ' order by Time desc limit 0, ".get_option('Nudalytics_numlog').";");
	else
		$list = $wpdb->get_results("SELECT * FROM $tablename WHERE Crawler != ' ' order by Time desc limit 0, 50;");
	foreach ($list as $data)
		echo '<ul class="nt">'.
			'<li class="w20">'.$data->Time.'</li>'.
			'<li class="w20">'.$data->Crawler.'</li>'.
			'<li class="w55">'.urldecode($data->URL).'</li>'.
			'</ul>';
?>
</div>
<?php
}
?>
Return current item: Nudalytics