📄 blocklist.php
字号:
<?php/*** @package Blocklist* @copyright (C) 2006 Websmurf* @author Websmurf* * --------------------------------------------------------------------------------* All rights reserved. Blocklist is a component for Joomla and Mambo. * You can use it to block certain ipadresses or ipblocks** This program is free software; you can redistribute it and/or* modify it under the terms of the Creative Commons - Attribution-NoDerivs 2.5 * license as published by the Creative Commons Organisation* http://creativecommons.org/licenses/by-nd/2.5/.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * --------------------------------------------------------------------------------**/// ensure this file is being included by a parent filedefined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );$_MAMBOTS->registerFunction( 'onStart', 'botCheckBlocked' );function botCheckBlocked(){ global $database, $mosConfig_absolute_path; $block = false; include($mosConfig_absolute_path . '/administrator/components/com_blocklist/configuration.php'); $content = file($mosConfig_absolute_path . '/administrator/components/com_blocklist/block.lst'); $lst = array(); for($i=0,$n=count($content);$i<$n;$i++){ $row = explode("|", $content[$i]); $lst[$row[0]] = $row[1]; } $ips = array_keys($lst); //check whole IP first if(in_array($_SERVER['REMOTE_ADDR'], $ips)){ $offset = array_search($_SERVER['REMOTE_ADDR'], $ips); $content = str_replace('{REASON}', $lst[$ips[$offset]], $bl_config['pagecontent']); $block = true; } $ip = explode(".", $_SERVER['REMOTE_ADDR']); //check 10.0.0.* if(in_array($ip[0] . '.' . $ip[1] . '.' . $ip[2] . '.*', $ips)){ $offset = array_search($ip[0] . '.' . $ip[1] . '.' . $ip[2] . '.*', $ips); $content = str_replace('{REASON}', $lst[$ips[$offset]], $bl_config['pagecontent']); $block = true; } //check 10.0.*.* if(in_array($ip[0] . '.' . $ip[1] . '.*.*', $ips)){ $offset = array_search($ip[0] . '.' . $ip[1] . '.*.*', $ips); $content = str_replace('{REASON}', $lst[$ips[$offset]], $bl_config['pagecontent']); $block = true; } //check 10.*.*.* if(in_array($ip[0] . '.*.*.*', $ips)){ $offset = array_search($ip[0] . '.*.*.*', $ips); $content = str_replace('{REASON}', $lst[$ips[$offset]], $bl_config['pagecontent']); $block = true; } if($block){ header('HTTP/1.0 403 Access Denied'); echo str_replace('</body>', '<div align="center">Powered by <a href="http://www.joomla-addons.org/blocklist-component.html" target="_blank" title="Joomla components, modules, plugins, hosting and services">Blocklist</a>' . "</div>\n</body>", $content); exit; }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -