logfile = $_af; $this->lockfile = $_af."lock"; if(!is_array($_allow)){ if($_allow=="")$_allow="all"; $this->allow[]=$_allow; } else $this->allow = $_allow; if(!is_array($_deny)){ if($_deny=="")$_deny="none"; $this->deny[]=$_deny; } else $this->deny = $_deny; $this->errormessae = ""; } // constructor end //----- アクセス権チェック function check(){ $this->errormessae = ""; $_ip = getenv("REMOTE_ADDR"); $_host = @gethostbyaddr($_ip); $_ref = getenv("HTTP_HOST"); $ret_code = false; //----- 実行許可ホストの確認 if($this->allow[0]!="all"){ $c = count($this->allow); for($i=0;$i<$c;$i++){ if(ereg($this->allow[$i],$_ref)){ $ret_code = true; $i = $c; } } } else $ret_code = true; if(!$ret_code){ $ptn = "ref"; $this->errormessage = "実行許可されていないホストです."; } elseif($this->deny[0]!="none"){ //----- アクセス拒否ホストの確認 $c = count($this->deny); for($i=0;$i<$c;$i++){ if(ereg($this->deny[$i],$_host)){ $ptn = "host"; $this->errormessage = "アクセス権がありません."; $ret_code = false; $i = $c; } } } //----- アタック履歴の保存 if(!$ret_code){ $_lffp = fopen($this->lockfile,"w"); flock($_lffp, LOCK_EX); $_fp = fopen($this->logfile,"a"); fputs($_fp,$ptn.",".time().",".$_ip.",".$_host.",".$_ref."\n"); fclose($_fp); @chmod($this->logfile,0666); flock($_lffp, LOCK_UN); fclose($_lffp); unlink($this->lockfile); } return $ret_code; } // check end function view(){ if(file_exists($this->logfile))readfile($this->logfile); } // view end } // class end ?>