*/ 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 '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $bans = @file($conf['cachedir'] . '/ipbanplugin.txt'); if (is_array($bans)) { foreach ($bans as $ban) { $fields = explode("\t", $ban); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } echo ''; echo ''; echo ''; echo '
' . $this->getLang('ip') . '' . $this->getLang('date') . '' . $this->getLang('by') . '' . $this->getLang('cause') . '' . $this->getLang('del') . '
' . hsc($fields[0]) . '' . strftime($conf['dformat'], $fields[1]) . '' . hsc($fields[2]) . '' . hsc($fields[3]) . '
'; echo '
' . $this->getLang('newban') . ':
'; echo ''; echo ' '; echo ''; echo ' '; echo ''; echo '
'; echo '
'; } }