<?php // Disallow direct access to this file for security reasons if (!defined("IN_MYBB")) { die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); } $page->add_breadcrumb_item("CloudFlare Manager", "index.php?module=cloudflare"); $page->add_breadcrumb_item("CloudFlare Overview", "index.php?module=cloudflare-overview"); if (!$mybb->input['action']) { $plugins->run_hooks("admin_cloudflare_overview_start"); $page->output_header("CloudFlare Manager - Overview"); if (!$cache->read('cloudflare_zone_id')) { $zone_id = get_cloudflare_zone_id(); if (isset($zone_id['error'])) { flash_message("Could not get zone ID: {$zone_id['error']}", "error"); die; } $cache->update('cloudflare_zone_id', $zone_id['zone_id']); } $sub_tabs['overview'] = array('title' => "Overview", 'link' => "index.php?module=cloudflare-overview", 'description' => "A general overview and summary of statistics and updates."); $sub_tabs['news'] = array('title' => "CloudFlare News", 'link' => "index.php?module=cloudflare-news", 'description' => "The latest news from the CloudFlare blog."); $page->output_nav_tabs($sub_tabs, 'overview'); if (dns_status($mybb->settings['cloudflare_domain']) == true) { $dns_status = "<a href=\"index.php?module=cloudflare-dns_active\"><span style=\"color:green;font-weight:bold;\">Active</span></a>"; } else { $dns_status = "<a href=\"index.php?module=cloudflare-dns_not_active\"><span style=\"color:red;font-weight:bold;\">Not Active</span></a>"; } if ($dns_status == "<a href=\"index.php?module=cloudflare-dns_not_active\"><span style=\"color:red;font-weight:bold;\">Not Active</span></a>") { flash_message("Your nameservers are not set correctly. Please change them to match the ones provided to you by CloudFlare.", "error"); } $today_request = cloudflare_statistics($cache->read('cloudflare_zone_id'), -1440);
function cloudflare_action_handler($action) { global $page, $plugins, $cache; $page->active_module = "cloudflare"; $actions = array('overview' => array('active' => 'overview', 'file' => 'cloudflare_overview.php'), 'purge_cache' => array('active' => 'purge_cache', 'file' => 'cloudflare_purge_cache.php'), 'purge_preloader_cache' => array('active' => 'purge_preloader_cache', 'file' => 'cloudflare_purge_preloader_cache.php'), 'dev_mode' => array('active' => 'dev_mode', 'file' => 'cloudflare_dev_mode.php'), 'cache_lvl' => array('active' => 'cache_lvl', 'file' => 'cloudflare_cache_lvl.php'), 'security_lvl' => array('active' => 'security_lvl', 'file' => 'cloudflare_security_lvl.php'), 'statistics' => array('active' => 'statistics', 'file' => 'cloudflare_statistics.php'), 'recent_visitors' => array('active' => 'recent_visitors', 'file' => 'cloudflare_recent_visitors.php'), 'blacklist' => array('active' => 'blacklist', 'file' => 'cloudflare_blacklist.php'), 'whitelist' => array('active' => 'whitelist', 'file' => 'cloudflare_whitelist.php'), 'help' => array('active' => 'help', 'file' => 'cloudflare_help.php'), 'knowledge_base' => array('active' => 'knowledge_base', 'file' => 'cloudflare_knowledge_base.php'), 'website' => array('active' => 'website', 'file' => 'cloudflare_website.php'), 'about_plugin' => array('active' => 'about_plugin', 'file' => 'cloudflare_about_plugin.php'), 'check_for_updates' => array('active' => 'check_for_updates', 'file' => 'cloudflare_check_for_updates.php'), 'report_bug' => array('active' => 'report_bug', 'file' => 'cloudflare_report_bug.php'), 'news' => array('active' => 'news', 'file' => 'cloudflare_news.php'), 'networkmap' => array('active' => 'networkmap', 'file' => 'cloudflare_networkmap.php'), 'dns_active' => array('active' => 'dns_active', 'file' => 'cloudflare_dns_active.php'), 'dns_not_active' => array('active' => 'dns_not_active', 'file' => 'cloudflare_dns_not_active.php'), 'challenge' => array('active' => 'challenge', 'file' => 'cloudflare_challenge.php'), 'change_log' => array('active' => 'change_log', 'file' => 'cloudflare_change_log.php'), 'recent_visitors_48' => array('active' => 'recent_visitors_48', 'file' => 'cloudflare_recent_visitors_48.php'), 'update_snapshot' => array('active' => 'update_snapshot', 'file' => 'cloudflare_update_snapshot.php'), 'ipv46' => array('active' => 'ipv46', 'file' => 'cloudflare_ipv46.php'), 'topthreats' => array('active' => 'topthreats', 'file' => 'cloudflare_topthreats.php'), 'whois' => array('active' => 'whois', 'file' => 'cloudflare_whois.php')); $actions = $plugins->run_hooks("admin_cloudflare_action_handler", $actions); $sub_menu = array(); $sub_menu['10'] = array("id" => "blacklist", "title" => "Black List", "link" => "index.php?module=cloudflare-blacklist"); $sub_menu['20'] = array("id" => "whitelist", "title" => "White List", "link" => "index.php?module=cloudflare-whitelist"); $sub_menu['30'] = array("id" => "challenge", "title" => "Challenge", "link" => "index.php?module=cloudflare-challenge"); $sub_menu['40'] = array("id" => "ipv46", "title" => "IPv6 Support", "link" => "index.php?module=cloudflare-ipv46"); $sub_menu['50'] = array("id" => "whois", "title" => "Whois Lookup", "link" => "index.php?module=cloudflare-whois"); $sub_menu = $plugins->run_hooks("admin_cloudflare_menu_access", $sub_menu); $sub_menu2 = array(); $sub_menu2['10'] = array("id" => "cache_lvl", "title" => "Cache Level", "link" => "index.php?module=cloudflare-cache_lvl"); $sub_menu2['20'] = array("id" => "purge_cache", "title" => "Purge Cache", "link" => "index.php?module=cloudflare-purge_cache"); $sub_menu2['30'] = array("id" => "purge_preloader_cache", "title" => "Purge Preloader Cache", "link" => "index.php?module=cloudflare-purge_preloader_cache"); $sub_menu2 = $plugins->run_hooks("admin_cloudflare_menu_cache", $sub_menu2); $sub_menu3 = array(); $sub_menu3['10'] = array("id" => "website", "title" => "Official Website", "link" => "index.php?module=cloudflare-website"); $sub_menu3['20'] = array("id" => "help", "title" => "Help Page", "link" => "index.php?module=cloudflare-help"); $sub_menu3['30'] = array("id" => "knowledge_base", "title" => "Knowledge Base", "link" => "index.php?module=cloudflare-knowledge_base"); $sub_menu3 = $plugins->run_hooks("admin_cloudflare_menu_help", $sub_menu3); $sub_menu4 = array(); $sub_menu4['10'] = array("id" => "about_plugin", "title" => "About Plugin", "link" => "index.php?module=cloudflare-about_plugin"); $sub_menu4['20'] = array("id" => "check_for_updates", "title" => "Check for Updates", "link" => "index.php?module=cloudflare-check_for_updates"); $sub_menu4['30'] = array("id" => "change_log", "title" => "Change Log", "link" => "index.php?module=cloudflare-change_log"); $sub_menu4['40'] = array("id" => "report_bug", "title" => "Report Bug", "link" => "index.php?module=cloudflare-report_bug"); $sub_men4 = $plugins->run_hooks("admin_cloudflare_menu_about", $sub_menu4); $sub_menu5 = array(); $sub_menu5['10'] = array("id" => "statistics", "title" => "Statistics", "link" => "index.php?module=cloudflare-statistics"); $sub_menu5['20'] = array("id" => "recent_visitors", "title" => "Recent Visitors", "link" => "index.php?module=cloudflare-recent_visitors"); $sub_menu5['40'] = array("id" => "update_snapshot", "title" => "Update Snapshot", "link" => "index.php?module=cloudflare-update_snapshot"); $sub_menu5 = $plugins->run_hooks("admin_cloudflare_menu_data", $sub_menu5); $sub_menu6 = array(); $sub_menu6['10'] = array("id" => "security_lvl", "title" => "Security Level", "link" => "index.php?module=cloudflare-security_lvl"); $sub_menu6['20'] = array("id" => "topthreats", "title" => "Top Threats", "link" => "index.php?module=cloudflare-topthreats"); $sub_menu6 = $plugins->run_hooks("admin_cloudflare_menu_security", $sub_menu6); if (!isset($actions[$action])) { $page->active_action = "overview"; } $sidebar = new SidebarItem("Access"); $sidebar->add_menu_items($sub_menu, $actions[$action]['active']); $page->sidebar .= $sidebar->get_markup(); $sidebar6 = new SidebarItem("Security"); $sidebar6->add_menu_items($sub_menu6, $actions[$action]['active']); $page->sidebar .= $sidebar6->get_markup(); $sidebar5 = new SidebarItem("Data"); $sidebar5->add_menu_items($sub_menu5, $actions[$action]['active']); $page->sidebar .= $sidebar5->get_markup(); $sidebar2 = new SidebarItem("Cache"); $sidebar2->add_menu_items($sub_menu2, $actions[$action]['active']); $page->sidebar .= $sidebar2->get_markup(); $sidebar3 = new SidebarItem("CloudFlare Support"); $sidebar3->add_menu_items($sub_menu3, $actions[$action]['active']); $page->sidebar .= $sidebar3->get_markup(); $sidebar4 = new SidebarItem("About Plugin"); $sidebar4->add_menu_items($sub_menu4, $actions[$action]['active']); $page->sidebar .= $sidebar4->get_markup(); if (!$cache->read('cloudflare_zone_id')) { $zone_id = get_cloudflare_zone_id(); if (isset($zone_id['error'])) { $page->active_action = "overview"; return "cloudflare_overview.php"; } } if (isset($actions[$action])) { $page->active_action = $actions[$action]['active']; return $actions[$action]['file']; } else { return "cloudflare_overview.php"; } }