public function __construct()
 {
     // Call the parent constructor (WP_Statistics::__constructor).
     parent::__construct();
     // We may have set the location based on a private IP address in the hits class, if so, don't bother looking it up again.
     if ($this->location == '000') {
         // Now get the location information from the MaxMind database.
         try {
             // Get the WordPress upload directory information, which is where we have stored the MaxMind database.
             $upload_dir = wp_upload_dir();
             // Create a new Reader and point it to the database.
             $reader = new Reader($upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb');
             // Look up the IP address
             $record = $reader->country($this->ip);
             // Get the location.
             $location = $record->country->isoCode;
             // MaxMind returns a blank for location if it can't find it, but we want to use 000 so replace it.
             if ($location == "") {
                 $location = "000";
             }
         } catch (Exception $e) {
             $location = "000";
         }
         // Store the location in the protected $location variable from the parent class.
         $this->location = $location;
     }
     // Check to see if we are excluded by the GeoIP rules.
     if (!$this->exclusion_match) {
         // Grab the excluded/included countries lists, force the country codes to be in upper case to match what the GeoIP code uses.
         $excluded_countries = explode("\n", strtoupper($this->get_option('excluded_countries')));
         $included_countries_string = trim(strtoupper($this->get_option('included_countries')));
         // We need to be really sure this isn't an empty string or explode will return an array with one entry instead of none.
         if ($included_countries_string == '') {
             $included_countries = array();
         } else {
             $included_countries = explode("\n", $included_countries_string);
         }
         // Check to see if the current location is in the excluded countries list.
         if (in_array($this->location, $excluded_countries)) {
             $this->exclusion_match = TRUE;
             $this->exclusion_reason = "geoip";
         } else {
             if (!in_array($this->location, $included_countries) && count($included_countries) > 0) {
                 $this->exclusion_match = TRUE;
                 $this->exclusion_reason = "geoip";
             }
         }
     }
 }
Exemple #2
0
<?php

ob_start();
include "set.php";
?>

<?php 
if (isset($_GET['id'])) {
    $domain_id = $_GET['id'];
    $limit = 0;
    if (isset($_GET['limit'])) {
        if ($_GET['limit'] == 'true') {
            $hits = Hits::find_by_domain_id_limit_100($domain_id);
            $limit = 1;
        } else {
            $hits = Hits::find_by_domain_id($domain_id);
        }
    } else {
        $hits = Hits::find_by_domain_id($domain_id);
    }
}
?>

<?php 
include $dir_public . 'hits.php';
?>

Exemple #3
0
function wp_statistics_shutdown_action()
{
    global $WP_Statistics;
    // If something has gone horribly wrong and $WP_Statistics isn't an object, bail out.  This seems to happen sometimes with WP Cron calls.
    if (!is_object($WP_Statistics)) {
        return;
    }
    // Create a new hit class, if we're GeoIP enabled, use GeoIPHits().
    if (class_exists('GeoIPHits')) {
        $h = new GeoIPHits();
    } else {
        $h = new Hits();
    }
    // Call the online users tracking code.
    if ($WP_Statistics->get_option('useronline')) {
        $h->Check_online();
    }
    // Call the visitor tracking code.
    if ($WP_Statistics->get_option('visitors')) {
        $h->Visitors();
    }
    // Call the visit tracking code.
    if ($WP_Statistics->get_option('visits')) {
        $h->Visits();
    }
    // Call the page tracking code.
    if ($WP_Statistics->get_option('pages')) {
        $h->Pages();
    }
    // Check to see if the GeoIP database needs to be downloaded and do so if required.
    if ($WP_Statistics->get_option('update_geoip')) {
        wp_statistics_download_geoip();
    }
    // Check to see if the browscap database needs to be downloaded and do so if required.
    if ($WP_Statistics->get_option('update_browscap')) {
        wp_statistics_download_browscap();
    }
    if ($WP_Statistics->get_option('send_upgrade_email')) {
        $WP_Statistics->update_option('send_upgrade_email', false);
        $blogname = get_bloginfo('name');
        $blogemail = get_bloginfo('admin_email');
        $headers[] = "From: {$blogname} <{$blogemail}>";
        $headers[] = "MIME-Version: 1.0";
        $headers[] = "Content-type: text/html; charset=utf-8";
        if ($WP_Statistics->get_option('email_list') == '') {
            $WP_Statistics->update_option('email_list', $blogemail);
        }
        wp_mail($WP_Statistics->get_option('email_list'), sprintf(__('WP Statistics %s installed on', 'wp_statistics'), WP_STATISTICS_VERSION) . ' ' . $blogname, "Installation/upgrade complete!", $headers);
    }
}
Exemple #4
0
<?php

ob_start();
include "set.php";
?>

<?php 
if (isset($_GET['name'])) {
    $name = $_GET['name'];
    $page = $_GET['page'];
    $domain = Domains::find_by_name($name);
    $domain->hits = $domain->hits + 1;
    $domain->save();
    $hit = Hits::make($domain->id, $page);
    $hit->save();
}
?>

<?php 
//include($dir_public.'update.php');
?>

Exemple #5
0
<?php

ob_start();
include "set.php";
?>

<?php 
if (isset($_GET['id'])) {
    $domain_id = $_GET['id'];
    $hits = Hits::count_distinct_by_domain_id($domain_id);
    $domain = Domains::find_by_id($domain_id);
}
?>

<?php 
include $dir_public . 'unique.php';
?>