File: /var/www/html/www.uscornatese.it/wp-content/plugins/angwp/excel.php
<?php
require_once('../../../wp-load.php');
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=export_stats.xls"); //File name extension was wrong
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
echo "<table border=1 class='table table-stripped' style='width:700px;'><tr><th>Banner</th><th>Impressions</th><th>Clicks</th><th>CTR</th></tr>";
global $wpdb;
$rs = $wpdb->get_results("SELECT post_title, sum(hits) as hits, sum(clicks) as clicks FROM wp_posts, wp_banner_stats where post_type = 'adni_banners' and banner_id = wp_posts.ID group by post_title;");
foreach ( $rs as $line ) {
echo "<tr>";
echo "<td>" . $line->post_title . "</td>";
echo "<td>" . $line->hits . "</td>";
echo "<td>" . $line->clicks . "</td>";
echo "<td>" . round(($line->clicks/$line->hits),4) . "</td>";
echo "</tr>";
}
echo "</table>";
?>