*/ class admin_plugin_ipban extends DokuWiki_Admin_Plugin { /** @inheritDoc */ function forAdminOnly() { return false; } /** @inheritDoc */ function getMenuSort() { return 41; } /** @inheritDoc */ function handle() { global $conf; global $INPUT; $ip = trim($INPUT->str('ip')); if ($ip) { require_once(__DIR__ . '/ip-lib/ip-lib.php'); $range = \IPLib\Factory::rangeFromString($ip); if ($range === null) { msg($this->getLang('badrange'), -1); } else { $newban = $ip . "\t" . time() . "\t" . $INPUT->server->str('REMOTE_USER'); $cause = trim(preg_replace('/[\n\r\t]+/', '', $INPUT->str('cause'))); $newban .= "\t" . $cause . "\n"; io_savefile($conf['cachedir'] . '/ipbanplugin.txt', $newban, true); } } $delip = $INPUT->extract('delip')->str('delip'); if ($delip) { $delip = preg_quote($delip, '/'); io_deleteFromFile( $conf['cachedir'] . '/ipbanplugin.txt', '/^' . $delip . '\t/', true ); } } /** @inheritDoc */ function html() { global $conf; echo $this->locale_xhtml('intro'); echo '
'; } }