</td> <td><?php echo $summary['total_clicks']; ?> <?php _e('clicks.', 'adrotate'); ?> </td> </tr> <tr> <td><?php _e('Click-Through-Rate', 'adrotate'); ?> </td> <td><?php echo adrotate_ctr($summary['total_clicks'], $summary['total_impressions']); ?> %, <?php _e('based on', 'adrotate'); ?> <?php echo $summary['total_impressions']; ?> <?php _e('impressions and', 'adrotate'); ?> <?php echo $summary['total_clicks']; ?> <?php _e('clicks.', 'adrotate');
function adrotate_manage() { global $wpdb, $current_user, $userdata, $blog_id, $adrotate_config, $adrotate_debug; $status = $file = $view = $ad_edit_id = ''; if (isset($_GET['status'])) { $status = esc_attr($_GET['status']); } if (isset($_GET['file'])) { $file = esc_attr($_GET['file']); } if (isset($_GET['view'])) { $view = esc_attr($_GET['view']); } if (isset($_GET['ad'])) { $ad_edit_id = esc_attr($_GET['ad']); } $now = adrotate_now(); $today = adrotate_date_start('day'); $in2days = $now + 172800; $in7days = $now + 604800; $in84days = $now + 7257600; if (isset($_GET['month']) and isset($_GET['year'])) { $month = esc_attr($_GET['month']); $year = esc_attr($_GET['year']); } else { $month = date("m"); $year = date("Y"); } $monthstart = mktime(0, 0, 0, $month, 1, $year); $monthend = mktime(0, 0, 0, $month + 1, 0, $year); if (isset($_GET['month']) and isset($_GET['year'])) { $month = esc_attr($_GET['month']); $year = esc_attr($_GET['year']); } else { $month = date("m"); $year = date("Y"); } $monthstart = mktime(0, 0, 0, $month, 1, $year); $monthend = mktime(0, 0, 0, $month + 1, 0, $year); ?> <div class="wrap"> <h1><?php _e('Ad Management', 'adrotate-pro'); ?> </h1> <?php if ($status > 0) { adrotate_status($status, array('file' => $file)); } ?> <?php $allbanners = $wpdb->get_results("SELECT `id`, `title`, `type`, `tracker`, `weight`, `desktop`, `mobile`, `tablet`, `budget`, `crate`, `irate` FROM `{$wpdb->prefix}adrotate` WHERE `type` = 'active' OR `type` = 'error' OR `type` = 'a_error' OR `type` = 'expired' OR `type` = '2days' OR `type` = '7days' OR `type` = 'disabled' ORDER BY `sortorder` ASC, `id` ASC;"); $activebanners = $errorbanners = $disabledbanners = false; foreach ($allbanners as $singlebanner) { $advertiser = ''; $starttime = $stoptime = 0; $starttime = $wpdb->get_var("SELECT `starttime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $singlebanner->id . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `starttime` ASC LIMIT 1;"); $stoptime = $wpdb->get_var("SELECT `stoptime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $singlebanner->id . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;"); if ($adrotate_config['enable_advertisers'] == 'Y') { $advertiser = $wpdb->get_var("SELECT `user_login` FROM `{$wpdb->prefix}adrotate_linkmeta`, `{$wpdb->users}` WHERE `{$wpdb->users}`.`id` = `{$wpdb->prefix}adrotate_linkmeta`.`user` AND `ad` = '" . $singlebanner->id . "' AND `group` = '0' AND `schedule` = '0' LIMIT 1;"); } $type = $singlebanner->type; if ($type == 'active' and $stoptime <= $now) { $type = 'expired'; } if ($type == 'active' and $stoptime <= $in2days) { $type = '2days'; } if ($type == 'active' and $stoptime <= $in7days) { $type = '7days'; } if (($singlebanner->crate > 0 or $singlebanner->irate > 0) and $singlebanner->budget < 1) { $type = 'expired'; } if ($type == 'active' or $type == '7days') { $activebanners[$singlebanner->id] = array('id' => $singlebanner->id, 'title' => $singlebanner->title, 'advertiser' => $advertiser, 'type' => $type, 'desktop' => $singlebanner->desktop, 'mobile' => $singlebanner->mobile, 'tablet' => $singlebanner->tablet, 'budget' => $singlebanner->budget, 'crate' => $singlebanner->crate, 'irate' => $singlebanner->irate, 'tracker' => $singlebanner->tracker, 'weight' => $singlebanner->weight, 'firstactive' => $starttime, 'lastactive' => $stoptime); } if ($type == 'error' or $type == 'a_error' or $type == 'expired' or $type == '2days') { $errorbanners[$singlebanner->id] = array('id' => $singlebanner->id, 'title' => $singlebanner->title, 'advertiser' => $advertiser, 'type' => $type, 'desktop' => $singlebanner->desktop, 'mobile' => $singlebanner->mobile, 'tablet' => $singlebanner->tablet, 'tracker' => $singlebanner->tracker, 'weight' => $singlebanner->weight, 'firstactive' => $starttime, 'lastactive' => $stoptime); } if ($type == 'disabled') { $disabledbanners[$singlebanner->id] = array('id' => $singlebanner->id, 'title' => $singlebanner->title, 'advertiser' => $advertiser, 'type' => $type, 'desktop' => $singlebanner->desktop, 'mobile' => $singlebanner->mobile, 'tablet' => $singlebanner->tablet, 'tracker' => $singlebanner->tracker, 'weight' => $singlebanner->weight, 'firstactive' => $starttime, 'lastactive' => $stoptime); } } ?> <div class="tablenav"> <div class="alignleft actions"> <a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-ads'); ?> "><?php _e('Manage', 'adrotate-pro'); ?> </a> | <a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-ads&view=addnew'); ?> "><?php _e('Add New', 'adrotate-pro'); ?> </a> | <a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-ads&view=import'); ?> "><?php _e('Import', 'adrotate-pro'); ?> </a> <?php if ($adrotate_config['stats'] == 1) { ?> | <a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-ads&view=fullreport'); ?> "><?php _e('Full Report', 'adrotate-pro'); ?> </a> <?php } ?> </div> </div> <?php if ($view == "") { // Show list of errorous ads if any if ($errorbanners) { include "dashboard/publisher/adverts-error.php"; } include "dashboard/publisher/adverts-main.php"; // Show disabled ads, if any if ($disabledbanners) { include "dashboard/publisher/adverts-disabled.php"; } } else { if ($view == "addnew" or $view == "edit") { include "dashboard/publisher/adverts-edit.php"; } else { if ($view == "report") { include "dashboard/publisher/adverts-report.php"; } else { if ($view == "import") { include "dashboard/publisher/adverts-import.php"; } else { if ($view == "fullreport") { $adrotate_stats = adrotate_prepare_fullreport(); if ($adrotate_stats['tracker'] > 0 and $adrotate_stats['clicks'] > 0) { $clicks = round($adrotate_stats['clicks'] / $adrotate_stats['tracker'], 2); } else { $clicks = 0; } $ctr = adrotate_ctr($adrotate_stats['clicks'], $adrotate_stats['impressions']); include "dashboard/publisher/fullreport.php"; } } } } } ?> <br class="clear" /> <?php adrotate_credits(); ?> <br class="clear" /> </div> <?php }
_e('Clicks', 'adrotate'); ?> </center></th> <th width="5%"><center><?php _e('CTR', 'adrotate'); ?> </center></th> </tr> </thead> <tbody> <?php foreach ($disabledbanners as $disbanner) { $stats = adrotate_stats($disbanner['id']); $grouplist = adrotate_ad_is_in_groups($disbanner['id']); // Prevent gaps in display $ctr = adrotate_ctr($stats['clicks'], $stats['impressions']); if ($adrotate_debug['dashboard'] == true) { echo "<tr><td> </td><td><strong>[DEBUG]</strong></td><td colspan='9'><pre>"; echo "Ad Specs: <pre>"; print_r($disbanner); echo "</pre>"; echo "Stats: <pre>"; print_r($stats); echo "</pre></td></tr>"; } $grouplist = adrotate_ad_is_in_groups($disbanner['id']); if ($disbanner['type'] == 'disabled') { $errorclass = ' row_inactive'; } else { $errorclass = ''; }
* Copyright 2008-2015 Arnan de Gans. All Rights Reserved. * ADROTATE is a registered trademark of Arnan de Gans. * COPYRIGHT NOTICES AND ALL THE COMMENTS SHOULD REMAIN INTACT. * By using this code you agree to indemnify Arnan de Gans from any * liability that might arise from it's use. ------------------------------------------------------------------------------------ */ $banner = $wpdb->get_row("SELECT `title`, `tracker` FROM `" . $wpdb->prefix . "adrotate` WHERE `id` = '{$ad_edit_id}';"); $stats = adrotate_stats($ad_edit_id); $stats_today = adrotate_stats($ad_edit_id, $today); //$stats_last_month = adrotate_stats($ad_edit_id, mktime(0, 0, 0, date("m")-1, 1, date("Y")), mktime(0, 0, 0, date("m")-1, date("t"), date("Y"))); $stats_last_month = adrotate_stats($ad_edit_id, mktime(0, 0, 0, date("m") - 1, 1, date("Y")), mktime(0, 0, 0, date("m"), 0, date("Y"))); $stats_this_month = adrotate_stats($ad_edit_id, mktime(0, 0, 0, date("m"), 1, date("Y")), mktime(0, 0, 0, date("m"), date("t"), date("Y"))); // Get Click Through Rate $ctr = adrotate_ctr($stats['clicks'], $stats['impressions']); $ctr_this_month = adrotate_ctr($stats_this_month['clicks'], $stats_this_month['impressions']); if ($adrotate_debug['publisher'] == true) { echo "<p><strong>[DEBUG] Ad Stats (all time)</strong><pre>"; print_r($stats); echo "</pre></p>"; echo "<p><strong>[DEBUG] Ad Stats (today)</strong><pre>"; print_r($stats_today); echo "</pre></p>"; } ?> <h3><?php _e('Statistics for advert', 'adrotate-pro'); ?> '<?php echo $banner->title; ?>