[WordPress][Hack] 管理画面へのアクセスを指定IPで制限

2006年12月30日 土曜日 18時12分
E-Mail This Post/Page Print This Post/Page

最近ちょっとうちの WordPress の挙動がおかしくなったので、取り掛かっていたプラグインの製作を途中で中断し、ちょっとしたセキュリティの対策に時間を費やしてみました。

以下のコードを wp-admin/admin-header.php の<?php の直下(2行目以下)に組み込みます。 これで、指定したIP以外からのアドミンパネル(管理画面)へのアクセスができなくなります。

PHP:
  1. # Admin Login IP Restriction Hack Start
  2.     $allowed_ips = array(
  3.         '36.36.322',
  4.         '21.45.75',
  5.         '77.3.45.222'
  6.     );
  7.     $user_ip = gethostbyname($_SERVER["REMOTE_ADDR"]);
  8.     foreach($allowed_ips as $allowed_ip) {
  9.         if(strstr($user_ip, $allowed_ip)) {
  10.             $allowed = true;
  11.         }
  12.     }
  13.     if($allowed !== true) {
  14.         $redirecting_url = trailingslashit(get_settings('siteurl')) . 'wp-login.php';
  15.         wp_clearcookie();
  16.         do_action('wp_logout');
  17.         nocache_headers();
  18.         wp_redirect($redirecting_url);
  19.         exit();  
  20.     }
  21. # Admin Login IP Restriction Hack End

設定箇所:
 

以下の部分で自分の使用しているローカルIPアドレスを入力します。好きなだけ付け足してください。ダイナミックIPアドレスの範囲が 例えば、'36.36.322.1~255' の場合、単に 36.36.322. と記入します。最後のドットをお忘れなく。でないと、 *.36.36.322 にもマッチしてしまいます。

$allowed_ips = array(
'36.36.322.',
'21.45.',
'77.3.45.222'
);

この方法はコアファイルを編集する形になっていますのでプラグイン化を検討中です。

Share This

この記事に関連する NEWS

この記事に関連するトピック

このエントリーへの Yahoogle Suggestions

One Response to “[WordPress][Hack] 管理画面へのアクセスを指定IPで制限”

[WordPress][News] IP Login Restriction 1.0j リリース! « ぱそずき :D)‐く

[…] 以前こちらの記事で、管理画面へのログインを指定IPで制限する方法を照会しましたが、それをプラグインにしました。 […]

Trackback this Post | Feed on comments to this Post

 

記事ヒット TOP 10

WordPress Tips from Social Bookmarks Jp

    There is no entries available for this category.

WordPress Tips from Social Bookmarks

    There is no entries available for this category.

WordPress Plugins from Social Bookmarks

    There is no entries available for this category.

Tag Cloud

admin Admin Drop Menus Admin Memo Admin Panel advanced drop menus array unique blog cron dabeya Dagon Design Sitemap Generator dropcap Edit N Place error Feedburner game google hack html HTML CSS Internet NEWS Permalink Redirect PHP phpBB2 plugin RSS scripts search stattraq template the content Ultimate Tag Warrior Web Management Windows XP Wordpress WP Plugins WPページ  拡張子 カスタマイズ カスタム関数 カテゴリー コード セキュリティ タグ トップページ トラックバック フィード 投稿 抜粋 日本語 時刻 時間 正規表現 表示 記事

サイト メニュー

Blogtimes image
ぱそずき :D)‐く © 2008
Close
E-mail It