Example #1
0
function wp_statistics_generate_words_postbox_content($ISOCountryCode, $count = 10)
{
    global $wpdb, $WP_Statistics;
    // Retrieve MySQL data for the search words.
    $search_query = wp_statistics_searchword_query('all');
    // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
    $tablename = $wpdb->prefix . 'statistics_';
    if ($WP_Statistics->get_option('search_converted')) {
        $tabletwo = $tablename . 'visitor';
        $tablename .= 'search';
        $result = $wpdb->get_results("SELECT * FROM `{$tablename}` INNER JOIN `{$tabletwo}` on {$tablename}.`visitor` = {$tabletwo}.`ID` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC  LIMIT 0, {$count}");
    } else {
        $tablename .= 'visitor';
        $result = $wpdb->get_results("SELECT * FROM `{$tablename}` WHERE {$search_query} ORDER BY `{$tablename}`.`ID` DESC  LIMIT 0, {$count}");
    }
    if (sizeof($result) > 0) {
        echo "<div class='log-latest'>";
        foreach ($result as $items) {
            if (!$WP_Statistics->Search_Engine_QueryString($items->referred)) {
                continue;
            }
            if (substr($items->ip, 0, 6) == '#hash#') {
                $ip_string = __('#hash#', 'wp_statistics');
            } else {
                $ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
            }
            if ($WP_Statistics->get_option('search_converted')) {
                $this_search_engine = $WP_Statistics->Search_Engine_Info_By_Engine($items->engine);
                $words = $items->words;
            } else {
                $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
                $words = $WP_Statistics->Search_Engine_QueryString($items->referred);
            }
            echo "<div class='log-item'>";
            echo "<div class='log-referred'>" . $words . "</div>";
            echo "<div class='log-ip'>" . date(get_option('date_format'), strtotime($items->last_counter)) . " - {$ip_string}</div>";
            echo "<div class='clear'></div>";
            echo "<div class='log-url'>";
            echo "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __('Map', 'wp_statistics') . "'>" . wp_statistics_icons('dashicons-location-alt', 'map') . "</a>";
            if ($WP_Statistics->get_option('geoip')) {
                echo "<img src='" . plugins_url('wp-statistics/assets/images/flags/' . $items->location . '.png') . "' title='{$ISOCountryCode[$items->location]}' class='log-tools'/>";
            }
            $this_search_engine = $WP_Statistics->Search_Engine_Info($items->referred);
            echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-search&referred={$this_search_engine['tag']}'><img src='" . plugins_url('wp-statistics/assets/images/' . $this_search_engine['image']) . "' class='log-tools' title='" . $this_search_engine['translated'] . "'/></a>";
            if (array_search(strtolower($items->agent), array("chrome", "firefox", "msie", "opera", "safari")) !== FALSE) {
                $agent = "<img src='" . plugins_url('wp-statistics/assets/images/') . $items->agent . ".png' class='log-tools' title='{$items->agent}'/>";
            } else {
                $agent = wp_statistics_icons('dashicons-editor-help', 'unknown');
            }
            echo "<a href='?page=" . WP_STATISTICS_OVERVIEW_PAGE . "&type=last-all-visitor&agent={$items->agent}'>{$agent}</a>";
            echo "<a href='" . htmlentities($items->referred, ENT_QUOTES) . "' title='" . htmlentities($items->referred, ENT_QUOTES) . "'>" . wp_statistics_icons('dashicons-admin-links', 'link') . " " . htmlentities($items->referred, ENT_QUOTES) . "</a></div>";
            echo "</div>";
        }
        echo "</div>";
    }
}
if ($total > 0) {
    // Instantiate pagination object with appropriate arguments
    $pagesPerSection = 10;
    $options = array(25, "All");
    $stylePageOff = "pageOff";
    $stylePageOn = "pageOn";
    $styleErrors = "paginationErrors";
    $styleSelect = "paginationSelect";
    $Pagination = new WP_Statistics_Pagination($total, $pagesPerSection, $options, false, $stylePageOff, $stylePageOn, $styleErrors, $styleSelect);
    $start = $Pagination->getEntryStart();
    $end = $Pagination->getEntryEnd();
    // Retrieve MySQL data
    if ($referred && $referred != '') {
        $search_query = wp_statistics_searchword_query($referred);
    } else {
        $search_query = wp_statistics_searchword_query('all');
    }
    $result = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$search_query} ORDER BY `{$wpdb->prefix}statistics_visitor`.`ID` DESC  LIMIT {$start}, {$end}");
    include_once dirname(__FILE__) . "/../functions/country-codes.php";
    $dash_icon = wp_statistics_icons('dashicons-location-alt', 'map');
    foreach ($result as $items) {
        if (!$WP_Statistics->Search_Engine_QueryString($items->referred)) {
            continue;
        }
        if (substr($items->ip, 0, 6) == '#hash#') {
            $ip_string = __('#hash#', 'wp_statistics');
            $map_string = "";
        } else {
            $ip_string = "<a href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank'>{$items->ip}</a>";
            $map_string = "<a class='show-map' href='http://www.geoiptool.com/en/?IP={$items->ip}' target='_blank' title='" . __('Map', 'wp_statistics') . "'>{$dash_icon}</a>";
        }
Example #3
0
function wp_statistics_searchword($search_engine = 'all', $time = 'total')
{
    global $wpdb, $WP_Statistics;
    // Get a complete list of search engines
    $search_query = wp_statistics_searchword_query($search_engine);
    // This function accepts several options for time parameter, each one has a unique SQL query string.
    // They're pretty self explanatory.
    switch ($time) {
        case 'today':
            $result = $wpdb->query("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d')}' AND {$search_query}");
            break;
        case 'yesterday':
            $result = $wpdb->query("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -1)}' AND {$search_query}");
            break;
        case 'week':
            $result = $wpdb->query("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -7)}' AND {$search_query}");
            break;
        case 'month':
            $result = $wpdb->query("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -30)}' AND {$search_query}");
            break;
        case 'year':
            $result = $wpdb->query("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -360)}' AND {$search_query}");
            break;
        case 'total':
            $result = $wpdb->query("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$search_query}");
            break;
        default:
            $result = $wpdb->query("SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', $time)}' AND {$search_query}");
            break;
    }
    return $result;
}
Example #4
0
function wp_statistics_searchword($search_engine = 'all', $time = 'total')
{
    global $wpdb, $WP_Statistics;
    // Determine if we're using the old or new method of storing search engine info and build the appropriate table name.
    $tablename = $wpdb->prefix . 'statistics_';
    if ($WP_Statistics->get_option('search_converted')) {
        $tablename .= 'search';
    } else {
        $tablename .= 'visitor';
    }
    // Get a complete list of search engines
    $search_query = wp_statistics_searchword_query($search_engine);
    // This function accepts several options for time parameter, each one has a unique SQL query string.
    // They're pretty self explanatory.
    switch ($time) {
        case 'today':
            $result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d')}' AND {$search_query}");
            break;
        case 'yesterday':
            $result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -1)}' AND {$search_query}");
            break;
        case 'week':
            $result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -7)}' AND {$search_query}");
            break;
        case 'month':
            $result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -30)}' AND {$search_query}");
            break;
        case 'year':
            $result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', -360)}' AND {$search_query}");
            break;
        case 'total':
            $result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE {$search_query}");
            break;
        default:
            $result = $wpdb->query("SELECT * FROM `{$tablename}` WHERE `last_counter` = '{$WP_Statistics->Current_Date('Y-m-d', $time)}' AND {$search_query}");
            break;
    }
    return $result;
}