ip_auth
Tag: PukiWiki Hack
この IP なら無条件で許可。
Pukiwiki Plus! i18n で確認したが、本家でも動くような気はする。
lib/auth.php に以下を追加
function read_auth($page, $auth_flag = TRUE, $exit_flag = TRUE)
{
global $read_auth, $read_auth_pages, $read_auth_pages_accept_ip;
global $_title;
if ($read_auth) {
if(ip_auth($page, $auth_flag, $exit_flag, $read_auth_pages_accept_ip, $_title['cannnotread'])) {
return TRUE;
}
}
return $read_auth ? basic_auth($page, $auth_flag, $exit_flag, $read_auth_pages, $_title['cannnotread']) : TRUE;
}
// IP authentication. allows ip without basic_auth
function ip_auth($page, $auth_flag, $exit_flag, $auth_pages_accept_ip, $title_cannot)
{
global $auth_method_type;
// Checked by:
$target_str = '';
if ($auth_method_type == 'pagename') {
$target_str = $page; // Page name
} else if ($auth_method_type == 'contents') {
$target_str = join('', get_source($page)); // Its contents
}
$accept_ip_list = array();
foreach($auth_pages_accept_ip as $key=>$val)
if (preg_match($key, $target_str))
$accept_ip_list = array_merge($accept_ip_list, explode(',', $val));
$auth = FALSE;
if (!empty($accept_ip_list)) {
if(isset($_SERVER['REMOTE_ADDR'])) {
foreach ($accept_ip_list as $ip) {
if(strpos($_SERVER['REMOTE_ADDR'], $ip) !== false) {
$auth = TRUE;
break;
}
}
}
}
return $auth;
}
edit_auth も同様に作成する(read の文字を edit に置換)
設定
pukiwiki.ini.php
// Accept specified IP without basic_auth $read_auth_pages_accept_ip = array( '#Private\/#' => '127.0.', );


