Contributed by: ivy on 土曜日, 9月 13 2025 @ 10:58 pm JST
Last modified on 土曜日, 9月 13 2025 @ 11:03 pm JST
/admin/, users.phpをIP制限する方法は。siteconfig.phpに制限のためのコードを追加します。
開発者はデバッグモードをON、管理画面アクセス許可
編集者はデバッグモードをOFF、管理画面アクセス許可
その他は一般画面のみ表示。管理画面アクセス不可
siteconfig.phpの最後に制限のためのコードを追加します。
/**
* Access control based on IP address
*
* - Developers (in $allowed_admin): Enable rootdebug and template_comments
* - Editors (in $allowed): Enable template_comments only
* - Other users:
* - If maintenance page is set, show it and exit
* - If accessing restricted paths, return 403 Forbidden
*/
// Editor
$allowed = [
'139.101.11.196',
'119.99.33.80'
];
// Admin
$allowed_admin = [
'209.39.33.55'
];
// Restricted path
$restricted = [
'/admin/',
'/users.php'
];
// Get user IP
$user_ip = $_SERVER['REMOTE_ADDR'];
// Developer check (first priority)
if (in_array($user_ip, $allowed_admin)) {
$_CONF['rootdebug'] = true;
return;
}
// Editor check
if (in_array($user_ip, $allowed)) {
return;
}
// Default settings (disabled)
$_CONF['rootdebug'] = false; // Disable developer mode
$_CONF['template_comments'] = false; // Disable template comments
// Restricted paths check
foreach ($restricted as $path) {
if (strpos($_SERVER['REQUEST_URI'], $path) !== false) {
header('HTTP/1.1 403 Forbidden');
exit;
}
}