public function counterize_feed_most_popular_posts24hrs($number = 10, $tn_width = 50, $tn_height = 50, $header_override = '')
 {
     global $wpdb;
     $onedayago = date('Y-m-d H:i:s', time() - 86400);
     $number = $wpdb->prepare("%d", $number);
     $sql = "SELECT COUNT( l.`id` ) AS `count`, c.`postID`, c.`url` AS url, w.`post_title` AS label " . " FROM `" . counterize_logTable() . "` l, `" . counterize_pageTable() . "` c, `" . $wpdb->posts . "` w " . " WHERE l.`pageID` = c.`pageID` " . " AND c.`postID` = w.`ID` " . " AND l.`timestamp` >= '{$onedayago}'" . " GROUP BY c.`postID` " . " ORDER BY `count` DESC " . " LIMIT {$number}";
     $rows = $wpdb->get_results($sql);
     $title = __('Most popular posts/pages for the last 24 hours', COUNTERIZE_PLUGIN_PAGES_TD);
     if (!empty($header_override)) {
         $title = $header_override;
     }
     $feed = new CounterizeFeed($title, __('Posts/pages', COUNTERIZE_PLUGIN_PAGES_TD));
     foreach ($rows as $row) {
         $label = trim(stripslashes($row->label));
         if (function_exists('has_post_thumbnail') && has_post_thumbnail($row->postID)) {
             $thumbnail_id = get_post_thumbnail_id($row->postID);
             $thumbnail_arr = wp_get_attachment_image_src($thumbnail_id, array($tn_width, $tn_height));
             $thumbnail_src = $thumbnail_arr[0];
             $img = new CounterizeFeedImg($thumbnail_src, $label, sprintf(__('Click here to view the post "%s"', COUNTERIZE_PLUGIN_PAGES_TD), $row->label), 'counterize_thumb', $tn_width, $tn_height);
             $feed->add_item_4($row->count, $label, $row->url, $img);
             unset($thumbnail_id, $thumbnail_arr, $thumbnail_src);
         } else {
             $feed->add_item_3($row->count, $label, $row->url);
         }
         unset($label);
     }
     unset($rows, $sql, $onedayago);
     $feed->refresh_percentages();
     return $feed;
 }
 public function counterize_feed_most_used_browsers($number = 10, $header_override = '')
 {
     global $wpdb;
     $number = $wpdb->prepare("%d", $number);
     $sql = "SELECT " . " \tSUM( `count` ) AS `count`, " . " \tCONCAT( CONCAT( `browserName`, ' ' ), `browserVersion` ) AS `label`, " . " \t`browserCode` AS `code`, " . " \t`browserURL` AS `url` " . " FROM `" . counterize_agentsTable() . "`" . " GROUP BY `label` " . " ORDER BY `count` DESC " . " LIMIT {$number}";
     $rows = $wpdb->get_results($sql);
     $title = __('Most used browsers', COUNTERIZE_PLUGIN_BROWSERS_TD);
     if (!empty($header_override)) {
         $title = $header_override;
     }
     $feed = new CounterizeFeed(__('Most used browsers', COUNTERIZE_PLUGIN_BROWSERS_TD), __('Browsers', COUNTERIZE_PLUGIN_BROWSERS_TD));
     foreach ($rows as $row) {
         $src = counterize_get_image_url($row->code);
         $name = $row->label;
         if (empty($row->code) || $row->code == ' ' || $row->code == 'unknown') {
             $label = __('Unknown', COUNTERIZE_PLUGIN_BROWSERS_TD);
         } else {
             $label = $name;
         }
         if (!empty($src)) {
             $img = new CounterizeFeedImg($src, $label, $label, 'browsericon');
             $feed->add_item_4($row->count, $label, $row->url, $img);
         } else {
             $feed->add_item_3($row->count, $label, $row->url);
         }
         unset($src, $name, $label);
     }
     unset($rows, $sql);
     $feed->refresh_percentages();
     return $feed;
 }
 public function counterize_feed_most_visiting_countries24hrs($number = 10, $header_override = '')
 {
     global $wpdb;
     $number = $wpdb->prepare("%d", $number);
     $onedayago = date('Y-m-d H:i:s', time() - 86400);
     $sql = "SELECT COUNT( m.id ) AS `count`, c.code, c.code AS label " . " FROM `" . counterize_logTable() . "` m, `" . counterize_countryTable() . "` c " . " WHERE m.countryID = c.countryID" . " AND m.timestamp >= '{$onedayago}'" . " GROUP BY c.code " . " ORDER BY `count` DESC " . " LIMIT {$number}";
     $rows = $wpdb->get_results($sql);
     $title = __('Most visiting countries for the last 24 hours', COUNTERIZE_PLUGIN_COUNTRIES_TD);
     if (!empty($header_override)) {
         $title = $header_override;
     }
     $feed = new CounterizeFeed($title, __('Countries', COUNTERIZE_PLUGIN_COUNTRIES_TD));
     foreach ($rows as $row) {
         $src = counterize_get_flag_url($row->code);
         $name = counterize_get_countryname($row->code);
         if (empty($row->code) || $row->code == ' ' || $row->code == '00') {
             $label = __('unknown', COUNTERIZE_PLUGIN_COUNTRIES_TD);
         } else {
             $label = $name;
         }
         if (!empty($src)) {
             $img = new CounterizeFeedImg($src, sprintf(__('National flag of %s', COUNTERIZE_PLUGIN_COUNTRIES_TD), $name), counterize_get_countryname($row->code) . " ({$row->code})", 'countryflag');
             $feed->add_item_4($row->count, $label, '', $img);
         } else {
             $feed->add_item_2($row->count, $label);
         }
         unset($src, $name, $label);
     }
     unset($rows, $sql);
     $feed->refresh_percentages();
     return $feed;
 }