"; print_r($data); print ""; exit; } */ function mk_data_w3a($str){ $str = str_replace("\t","",$str); $str = "\t".$str; return $str; } //拒否リスト読み込み function exclude_read($uri){ if(file_exists($uri)){ if($arr_exclude = @file($uri)){ $arr_exclude = @array_unique($arr_exclude); return $arr_exclude; } } } //配列に指定値があるかチェック function inc_array($str,$arr){ $retval = FALSE; if(is_array($arr)){ foreach($arr as $v){ if(eregi(trim($v), trim($str))){ $retval = TRUE; break; } } } return $retval; } /*======================================*/ /* w3Analyzerディレクトリパス取得 */ /*======================================*/ //PHP_SELF or SCRIPT_NAME $sn = ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER["SCRIPT_NAME"]); //w3Analyzerディレクトリパス編集 $acc_path = eregi_replace("^(/|\./)", "", $acc_path)."/"; $sn = eregi_replace("^(/|\./)", "", $sn); $sn = str_replace("/", "../", eregi_replace("[^/]", "", $sn)); $acc_path = $sn.$acc_path; unset($sn); if(file_exists($acc_path."inc/config.inc")){ /*======================================*/ /* 設定の読み込み等 */ /*======================================*/ @include_once($acc_path."inc/config.inc"); $w3a_logfile = $acc_path.$logdir.$logpref.date("Ym").$logext; /*======================================*/ /* 拒否リストの読み込み */ /*======================================*/ unset($exclude); $exclude_fn = $acc_path.$datadir."exclude_hosts.txt"; if(file_exists($exclude_fn)) $exclude["hosts"] = exclude_read($exclude_fn); $exclude_fn = $acc_path.$datadir."exclude_urls.txt"; if(file_exists($exclude_fn)) $exclude["urls"] = exclude_read($exclude_fn); $exclude_fn = $acc_path.$datadir."exclude_uas.txt"; if(file_exists($exclude_fn)) $exclude["uas"] = exclude_read($exclude_fn); unset($exclude_fn); /*======================================*/ /* メイン処理 */ /*======================================*/ //初期化 $w3a_buf = array(); //HOSTの設定 $w3a_buf["host"] = gethostbyaddr($_SERVER["REMOTE_ADDR"]); $write_flg = true; //除外処理 if(inc_array($w3a_buf["host"],$exclude["hosts"])) $write_flg = false; if(inc_array($_SERVER["REMOTE_ADDR"],$exclude["hosts"])) $write_flg = false; if(inc_array($_SERVER["HTTP_REFERER"],$exclude["urls"])) $write_flg = false; if(inc_array($_SERVER["HTTP_USER_AGENT"],$exclude["uas"])) $write_flg = false; //パスとリファラーの設定 if(isset($_GET["ref"])){ $w3a_buf["path"] = $_SERVER["HTTP_REFERER"]; $w3a_buf["path"] = @ereg_replace("(https?|ftp|news)(://[[:alnum:]\+\$\;\?\.%,!#~*:@&=_-]+)(/.*)","\\3",$w3a_buf["path"]); $w3a_buf["ref"] = $_GET["ref"]; }else{ $w3a_buf["path"] = $_SERVER["SCRIPT_NAME"]; $w3a_buf["ref"] = $_SERVER["HTTP_REFERER"]; } //ユーザーエージェントの設定 $w3a_buf["ua"] = $_SERVER["HTTP_USER_AGENT"]; //追加モードで開く if($write_flg && $fn = @fopen($w3a_logfile,"a+")){ //書き込みバッファ0に PHP4.3以上 if(function_exists('stream_set_write_buffer')) @stream_set_write_buffer($fn, 0); //ファイルロック flock($fn,LOCK_EX); fwrite($fn,date("d,D,H,i,s")); fwrite($fn,mk_data_w3a($w3a_buf["path"])); fwrite($fn,mk_data_w3a($w3a_buf["host"])); fwrite($fn,mk_data_w3a($w3a_buf["ref"])); fwrite($fn,mk_data_w3a($w3a_buf["ua"])); fwrite($fn,"\n"); //ロック解除 flock($fn,LOCK_UN); fclose($fn); } unset($w3a_buf,$w3a_logfile); /*======================================*/ /* HTML用(1X1透明画像出力) */ /*======================================*/ if(isset($_GET["ref"])){ header("Content-Type: image/gif"); echo base64_decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="); exit; } } unset($acc_path); ?>