//LogZ 表示部 200/11/11
extract($_POST);
if($url) header( "Location: $url");
$gif="bar.gif";
$logdir = "./log/";
$jisa=0;
$page_def=50;
$ppp=1;
if(empty($log)) $log=date("Y_m",mktime()+60*60*$jisa);
?>
echo "$log-$mode"; ?>
$yyyy = substr($log, 0, 4);
$dd = substr($log, 4, 6);
echo "$yyyy 年 $dd 月
\n";
echo "
//--date sample 2000/10/31 [Thu] 18:02:44--//
function key_sort(){
global $count,$i,$gif;
krsort($count);
reset($count);
while(list($w_key, $w_val) = each($count)):
$percent = sprintf("%2.1f",(($w_val/$i) * 100));
$graph = (int)$percent * 5;
echo "\n$w_key | \n";
echo "$w_val | \n";
echo "$percent% | \n";
echo " | \n";
echo "
\n";
endwhile;
}
function ar_sort(){
global $count,$i,$gif,$mode;
arsort($count);
reset($count);
while(list($w_key, $w_val) = each($count)):
$percent = sprintf("%2.1f",(($w_val/$i) * 100));
$graph = (int)$percent * 4;
echo "\n";
if($mode == "referer" && ereg("^http://", $w_key)):
echo "
$w_key | \n";
else:
echo "$w_key | \n";
endif;
echo "$w_val | \n";
echo "$percent% | \n";
echo " | \n";
echo "
\n";
endwhile;
}
$log = $logdir . $log;
if (!file_exists($log)) die("データがありません");
$buf = @file($log);
while(list($key, $val)=each($buf)):
htmlspecialchars($val);
list($now,$date,$host,$agent,$ref) = explode("\t", $val);
switch($mode):
case 'host':
if($ppp):
$host =eregi_replace("(.*)\.(.*\.(ad\.jp$|ne\.jp$|or\.jp$))",
"*.\\2", $host);
$host =eregi_replace("(.*)\.(.*\.(ac\.jp$|go\.jp$|co\.jp$))",
"\\1.\\2", $host);
endif;
$count[$host]++;
break;
case 'agent':
$count[$agent]++;
break;
case 'referer':
$count[$ref]++;
break;
case 'date':
list($k_date,$k_youbi,$suf) = explode(" ", $date);
$k_date .= $youbi;
$count[$k_date]++;
break;
case 'hour':
list($p_da,$p_you,$p_time) = explode(" ", $date);
list($hour,$sec) = explode(":", $p_time);
$count[$hour]++;
break;
case 'youbi':
list($t_date,$youbi,$suf) = explode(" ", $date);
$count[$youbi]++;
break;
endswitch;
$i++;
endwhile;
echo "Total $i Hits
";
?>
if($mode): ?>
echo $mode; ?> |
件数 |
割合 |
グラフ |
switch($mode):
case 'youbi':
$you_a = array('[Sun]','[Mon]','[Tue]','[Wed]','[Thu]','[Fri]','[Sat]');
while(list(, $y_val) = each($you_a)):
$percent = sprintf("%2.1f",(($count[$y_val]/$i) * 100));
$graph = (int)$percent * 5;
echo "\n$y_val | \n";
echo "$count[$y_val] | \n";
echo "$percent% | \n";
echo " | \n";
echo "
\n";
endwhile;
break;
case 'hour':
key_sort();
break;
case 'date':
key_sort();
break;
default:
ar_sort();
endswitch;
echo "
\n";
else:
?>
日付 |
ホスト |
ブラウザ |
リンク元 |
$lastlog = file ($log);
$logsize = sizeof($lastlog);
if($page) $start = $logsize - $page;
else $start = $logsize;
$end = $start - $page_def;
if($end < 0) $end = 0;
for($c = $start; $c >= $end ;$c--):
htmlspecialchars($lastlog[$c]);
list($now,$date,$host,$agent,$ref) = explode("\t", $lastlog[$c]);
if($ppp):
$host =ereg_replace("(.*)\.(.*\.(ad\.jp$|ne\.jp$|or\.jp$))",
"*.\\2", $host);
endif;
$date = substr($date, strpos($date, "/")+1);
$agent = ereg_replace("Mozilla/4.0 \(compatible;", "", $agent);
echo "\n";
echo "$date | \n";
echo "$host | \n";
echo "$agent | \n";
if(eregi("^http://", $ref)):
echo "$ref | \n";
else:
echo "$ref | \n";
endif;
echo "
\n";
$cc++;
endfor;
echo "\n
\n\n";
$logday = substr(strrchr($log, "/"), 1);
$prev = $page - $page_def;
if($page && $prev > 0):
?>
|
endif;
$next = $page + $page_def;
if($cc > $page_def):
?>
|
endif;
echo "
";
endif; // end mode
?>