function cerber_activate() { global $wpdb, $wp_version; cerber_load_lang(); if (version_compare(CERBER_REQ_PHP, phpversion(), '>')) { cerber_stop_activating('<h3>' . sprintf(__('The WP Cerber requires PHP %s or higher. You are running', 'cerber'), CERBER_REQ_PHP) . ' ' . phpversion() . '</h3>'); } if (version_compare(CERBER_REQ_WP, $wp_version, '>')) { cerber_stop_activating('<h3>' . sprintf(__('The WP Cerber requires WordPress %s or higher. You are running', 'cerber'), CERBER_REQ_WP) . ' ' . $wp_version . '</h3>'); } // Tables $db_errors = array(); if (!$wpdb->get_row("SHOW TABLES LIKE '" . CERBER_LOG_TABLE . "'")) { if (!$wpdb->query("\n\n\tCREATE TABLE IF NOT EXISTS " . CERBER_LOG_TABLE . " (\n `ip` varchar(39) CHARACTER SET ascii NOT NULL COMMENT 'Remote IP',\n `user_login` varchar(60) NOT NULL COMMENT 'Login from POST request',\n `user_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n `stamp` bigint(20) unsigned NOT NULL COMMENT 'Unix timestamp',\n `activity` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'What''s happen?',\n KEY `ip` (`ip`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Cerber actions log';\n\n\n\t\t\t\t")) { $db_errors[] = $wpdb->last_error; } } if (!$wpdb->get_row("SHOW TABLES LIKE '" . CERBER_ACL_TABLE . "'")) { if (!$wpdb->query("\n\n\tCREATE TABLE IF NOT EXISTS " . CERBER_ACL_TABLE . " (\n `ip` varchar(39) CHARACTER SET ascii NOT NULL COMMENT 'IP',\n `tag` char(1) NOT NULL COMMENT 'Type: B or W',\n `comments` varchar(250) NOT NULL,\n UNIQUE KEY `ip` (`ip`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Cerber IP access lists';\n\n\t\t\t\t")) { $db_errors[] = $wpdb->last_error; } } if (!$wpdb->get_row("SHOW TABLES LIKE '" . CERBER_BLOCKS_TABLE . "'")) { if (!$wpdb->query("\n\n\tCREATE TABLE IF NOT EXISTS " . CERBER_BLOCKS_TABLE . " (\n `ip` varchar(39) CHARACTER SET ascii NOT NULL COMMENT 'Remote IP',\n `block_until` bigint(20) unsigned NOT NULL COMMENT 'Unix timestamp',\n `reason` varchar(250) NOT NULL COMMENT 'Why was blocked',\n UNIQUE KEY `ip` (`ip`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='List of blocked IP';\n\n\t\t\t\t")) { $db_errors[] = $wpdb->last_error; } } if ($db_errors) { cerber_stop_activating('<h3>' . __("Can't activate WP Cerber due to a database error.", 'cerber') . '</h3><p>' . implode('<p>', $db_errors)); } cerber_cookie1(); cerber_disable_citadel(); cerber_get_groove(); cerber_add_white(cerber_get_subnet(cerber_get_ip())); // Protection for non-experienced user update_site_option('cerber_admin_message', __('WP Cerber is now active and has started protecting your site.', 'cerber') . ' <a href="' . admin_url(cerber_get_opage()) . '">' . __('Check settings here', 'cerber') . '.</a>'); $opt = cerber_get_options(); $opt = array_filter($opt); if (!empty($opt)) { return; } update_site_option(CERBER_OPT, cerber_get_defaults()); }
function cerber_action_links($actions, $plugin_file, $plugin_data, $context) { if ($plugin_file == cerber_plug_in()) { $link[] = '<a href="' . admin_url(cerber_get_opage()) . '">' . __('Settings') . '</a>'; $link[] = '<a href="' . admin_url(cerber_get_opage() . '&tab=acl') . '">' . __('Access Lists', 'cerber') . '</a>'; $actions = array_merge($link, $actions); } return $actions; }