ページへ戻る

− Links

 印刷 

XOOPS サイトの IPv6 対応の私的メモ の変更点 :: XOOPS マニア

UsersWiki:nao-pon/blog/2017-02-14 の変更点

« Prev[3]  
2: 2017-02-14 (火) 20:14:09 nao-pon[4] ソース[5] 現: 2017-02-14 (火) 21:57:55 nao-pon[4] ソース[6]
Line 18: Line 18:
- online テーブルの online_ip カラムの文字数拡張(39文字) - online テーブルの online_ip カラムの文字数拡張(39文字)
 +- protector モジュールの class/protector.php ip_match() の IPv6 対応(後述)
- protector モジュールの一般設定 信頼できる IP に ^::1$ と ^fe80:: を追加 - protector モジュールの一般設定 信頼できる IP に ^::1$ と ^fe80:: を追加
- protector モジュールの管理画面の BadIP のリストアップとその保存処理で、有効時間とIPのセパレーターを ":" から "-" に変更(trust/modules/protector/admin/index.php) - protector モジュールの管理画面の BadIP のリストアップとその保存処理で、有効時間とIPのセパレーターを ":" から "-" に変更(trust/modules/protector/admin/index.php)
Line 26: Line 27:
- protector の BadIP の登録で IPv6 のプレフィクス長を管理画面で指定できるようにする。 - protector の BadIP の登録で IPv6 のプレフィクス長を管理画面で指定できるようにする。
 +
 +** 詳細メモ [#c7b0e9f9]
 +
 +*** class/protector.php ip_match() [#v00f8c71]
 +#code(php,366-){{
 +function ip_match( $ips )
 +{
 +    foreach( $ips as $ip => $info ) {
 +     if( $ip ) {
 +     $ip = strtolower($ip);
 +     switch( substr( $ip , -1 ) ) {
 +     case '.' :
 +     case ':' :
 +     // foward match
 +     if( substr( @$_SERVER['REMOTE_ADDR'] , 0 , strlen( $ip ) ) == $ip ) {
 +     $this->ip_matched_info = $info ;
 +     return true ;
 +     }
 +     break ;
 +     case '0' :
 +     case '1' :
 +     case '2' :
 +     case '3' :
 +     case '4' :
 +     case '5' :
 +     case '6' :
 +     case '7' :
 +     case '8' :
 +     case '9' :
 +     case 'a' :
 +     case 'b' :
 +     case 'c' :
 +     case 'd' :
 +     case 'e' :
 +     case 'f' :
 +     // full match
 +     if( @$_SERVER['REMOTE_ADDR'] == $ip ) {
 +     $this->ip_matched_info = $info ;
 +     return true ;
 +     }
 +     break ;
 +     default :
 +     // perl regex
 +     if( @preg_match( $ip , @$_SERVER['REMOTE_ADDR'] ) ) {
 +     $this->ip_matched_info = $info ;
 +     return true ;
 +     }
 +     break ;
 +     }
 +     }
 +    }
 +    $this->ip_matched_info = null ;
 +    return false ;
 +}
 +}}
RIGHT:&font(90%){&page_comments;}; RIGHT:&font(90%){&page_comments;};
#navi #navi
« Prev[3]