}
 $month = objectToArray(cloudflare_statistics(20)->response);
 foreach ($month['result'] as $n => $data) {
     $stats = $data[0];
     $bandwidth_month = $stats['bandwidthServed'];
     $total_bandwidth_month = $bandwidth_month['user'];
     $total_bandwidth_month = (int) $total_bandwidth_month * 1024;
     $bandwidth_sent_month = $bandwidth_month['cloudflare'];
     $bandwidth_sent_month = (int) $bandwidth_sent_month * 1024;
     $saved_bandwidth_month = $total_bandwidth_month - $bandwidth_sent_month;
     $requests_month = $stats['requestsServed'];
     $total_requests_month = number_format($requests_month['cloudflare']);
     $sent_requests_month = number_format($requests_month['user']);
     $saved_requests_month = number_format($requests_month['cloudflare'] - $requests_month['user']);
 }
 $week = objectToArray(cloudflare_statistics(30)->response);
 foreach ($week['result'] as $n => $data) {
     $stats = $data[0];
     $bandwidth_week = $stats['bandwidthServed'];
     $total_bandwidth_week = $bandwidth_week['user'];
     $total_bandwidth_week = (int) $total_bandwidth_week * 1024;
     $bandwidth_sent_week = $bandwidth_week['cloudflare'];
     $bandwidth_sent_week = (int) $bandwidth_sent_week * 1024;
     $saved_bandwidth_week = $total_bandwidth_week - $bandwidth_sent_week;
     $requests_week = $stats['requestsServed'];
     $total_requests_week = number_format($requests_week['cloudflare']);
     $sent_requests_week = number_format($requests_week['user']);
     $saved_requests_week = number_format($requests_week['cloudflare'] - $requests_week['user']);
 }
 $table = new Table();
 $table->construct_header("Type", array("colspan" => 1));
 }
 $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);
 // see https://api.cloudflare.com/#zone-analytics-dashboard
 $today_results = array('pageviews' => $today_request->result->totals->pageviews->all, 'uniques' => $today_request->result->totals->uniques->all, 'threats' => $today_request->result->totals->threats->all, 'bandwidth' => $today_request->result->totals->bandwidth->all, 'bandwidth_cached' => $today_request->result->totals->bandwidth->cached);
 $week_request = cloudflare_statistics($cache->read('cloudflare_zone_id'), -10080);
 $week_results = array('pageviews' => $week_request->result->totals->pageviews->all, 'uniques' => $week_request->result->totals->uniques->all, 'threats' => $week_request->result->totals->threats->all, 'bandwidth' => $week_request->result->totals->bandwidth->all, 'bandwidth_cached' => $week_request->result->totals->bandwidth->cached);
 $table = new Table();
 $table->construct_header("API Details", array("colspan" => 2));
 $table->construct_header("", array("colspan" => 2));
 $table->construct_cell("<strong>API URL</strong>", array('width' => '25%'));
 $table->construct_cell("https://api.cloudflare.com/client/v4/", array('width' => '25%'));
 $table->construct_cell("<strong>Plugin Version</strong>", array('width' => '200'));
 $table->construct_cell(get_version(), array('width' => '200'));
 $table->construct_row();
 $table->construct_cell("<strong>Domain</strong>", array('width' => '25%'));
 $table->construct_cell(htmlspecialchars_uni($mybb->settings['cloudflare_domain']), array('width' => '25%'));
 $table->construct_cell("<strong>DNS Status</strong>", array('width' => '25%'));
 $table->construct_cell($dns_status, array('width' => '25%'));
 $table->construct_row();
 $table->construct_cell("<strong>Email Address</strong>", array('width' => '25%'));
$page->add_breadcrumb_item("Overview", "index.php?module=cloudflare-overview");
if (!$mybb->input['action']) {
    $plugins->run_hooks("admin_cloudflare_overview_start");
    $page->output_header("CloudFlare Manager - Overview");
    $sub_tabs['overview'] = array('title' => "Overview", 'link' => "index.php?module=cloudflare-overview", 'description' => "Information about your API key, email and more.");
    $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 = objectToArray(cloudflare_statistics(40)->response);
    foreach ($today['result'] as $n => $data) {
        $stats = $data[0];
        $pageviews = $stats['trafficBreakdown'];
        $pageviews = $pageviews['pageviews'];
        $unique = $stats['trafficBreakdown'];
        $unique = $unique['uniques'];
        $threats = $unique['threat'];
        $unique = $unique['regular'] + $unique['crawler'] + $unique['threat'];
        $pageviews = $pageviews['regular'] + $pageviews['crawler'] + $pageviews['threat'];
        $bandwidth_today = $stats['bandwidthServed'];
        $total_bandwidth_today = $bandwidth_today['user'];
        $total_bandwidth_today = (int) $total_bandwidth_today * 1024;
        $bandwidth_sent_today = $bandwidth_today['cloudflare'];
        $bandwidth_sent_today = (int) $bandwidth_sent_today * 1024;
        $saved_bandwidth_today = $total_bandwidth_today - $bandwidth_sent_today;