Example #1
0
</center></th>
			<th width="15%"><?php 
_e('Visible until', 'adrotate');
?>
</th>
		</tr>
		</thead>

		<tbody>
		<?php 
if ($ads) {
    $class = '';
    foreach ($ads as $ad) {
        $stoptime = $wpdb->get_var("SELECT `stoptime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $ad->id . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
        if ($adrotate_config['stats'] == 1) {
            $stats = adrotate_stats($ad->id);
        }
        $errorclass = '';
        if ($ad->type == 'error') {
            $errorclass = ' row_error';
        }
        if ($stoptime <= $in2days or $stoptime <= $in7days) {
            $errorclass = ' row_urgent';
        }
        if ($stoptime <= $now) {
            $errorclass = ' row_inactive';
        }
        $class = 'alternate' != $class ? 'alternate' : '';
        $class = $errorclass != '' ? $errorclass : $class;
        ?>
			    <tr class='<?php 
function adrotate_prepare_advertiser_report($user, $ads)
{
    global $wpdb;
    if ($ads) {
        $stats['ad_amount'] = count($ads);
        if (empty($stats['total_impressions'])) {
            $stats['total_impressions'] = 0;
        }
        if (empty($stats['total_clicks'])) {
            $stats['total_clicks'] = 0;
        }
        if (empty($stats['thebest'])) {
            $stats['thebest'] = array('title' => __('Not found', 'adrotate-pro'), 'clicks' => 0);
        }
        if (empty($stats['theworst'])) {
            $stats['theworst'] = array('title' => __('Not found', 'adrotate-pro'), 'clicks' => 0);
        }
        foreach ($ads as $ad) {
            $result = adrotate_stats($ad['id']);
            $stats['total_impressions'] = $stats['total_impressions'] + $result['impressions'];
            $stats['total_clicks'] = $stats['total_clicks'] + $result['clicks'];
            unset($result);
        }
        $stats['thebest'] = $wpdb->get_row($wpdb->prepare("\n\t\tSELECT `" . $wpdb->prefix . "adrotate`.`title`, SUM(`" . $wpdb->prefix . "adrotate_stats`.`clicks`) as `clicks` \n\t\tFROM `" . $wpdb->prefix . "adrotate`, `" . $wpdb->prefix . "adrotate_linkmeta`, `" . $wpdb->prefix . "adrotate_stats` \n\t\tWHERE `" . $wpdb->prefix . "adrotate`.`id` = `" . $wpdb->prefix . "adrotate_linkmeta`.`ad` \n\t\tAND `" . $wpdb->prefix . "adrotate_linkmeta`.`ad` = `" . $wpdb->prefix . "adrotate_stats`.`ad` \n\t\tAND `" . $wpdb->prefix . "adrotate`.`tracker` = 'Y' \n\t\tAND `" . $wpdb->prefix . "adrotate`.`type` = 'active' \n\t\tAND `" . $wpdb->prefix . "adrotate_linkmeta`.`user` = %d\n\t\tGROUP BY `" . $wpdb->prefix . "adrotate`.`id`\n\t\tORDER BY `" . $wpdb->prefix . "adrotate_stats`.`clicks` DESC LIMIT 1;\n\t\t", $user), ARRAY_A);
        $stats['theworst'] = $wpdb->get_row($wpdb->prepare("\n\t\tSELECT `" . $wpdb->prefix . "adrotate`.`title`, SUM(`" . $wpdb->prefix . "adrotate_stats`.`clicks`) as `clicks` \n\t\tFROM `" . $wpdb->prefix . "adrotate`, `" . $wpdb->prefix . "adrotate_linkmeta`, `" . $wpdb->prefix . "adrotate_stats` \n\t\tWHERE `" . $wpdb->prefix . "adrotate`.`id` = `" . $wpdb->prefix . "adrotate_linkmeta`.`ad` \n\t\tAND `" . $wpdb->prefix . "adrotate_linkmeta`.`ad` = `" . $wpdb->prefix . "adrotate_stats`.`ad` \n\t\tAND `" . $wpdb->prefix . "adrotate`.`tracker` = 'Y'\n\t\tAND `" . $wpdb->prefix . "adrotate`.`type` = 'active'\n\t\tAND `" . $wpdb->prefix . "adrotate_linkmeta`.`user` = %d\n\t\tGROUP BY `" . $wpdb->prefix . "adrotate`.`id`\n\t\tORDER BY `" . $wpdb->prefix . "adrotate_stats`.`clicks` ASC LIMIT 1;\n\t\t", $user), ARRAY_A);
        return $stats;
    }
}
Example #3
0
function adrotate_filter_schedule($selected, $banner)
{
    global $wpdb, $adrotate_config, $adrotate_debug;
    $now = adrotate_now();
    if ($adrotate_debug['general'] == true) {
        echo "<p><strong>[DEBUG][adrotate_filter_schedule()] Filtering banner</strong><pre>";
        print_r($banner->id);
        echo "</pre></p>";
    }
    // Get schedules for advert
    $schedules = $wpdb->get_results("SELECT `" . $wpdb->prefix . "adrotate_schedule`.`id`, `starttime`, `stoptime`, `maxclicks`, `maximpressions` FROM `" . $wpdb->prefix . "adrotate_schedule`, `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `schedule` = `" . $wpdb->prefix . "adrotate_schedule`.`id` AND `ad` = '" . $banner->id . "' ORDER BY `starttime` ASC LIMIT 1;");
    $schedule = $schedules[0];
    if ($adrotate_debug['general'] == true) {
        echo "<p><strong>[DEBUG][adrotate_filter_schedule] Ad " . $banner->id . " - Has schedule (id: " . $schedule->id . ")</strong><pre>";
        echo "<br />Start: " . $schedule->starttime . " (" . date("F j, Y, g:i a", $schedule->starttime) . ")";
        echo "<br />End: " . $schedule->stoptime . " (" . date("F j, Y, g:i a", $schedule->stoptime) . ")";
        echo "</pre></p>";
    }
    if ($now < $schedule->starttime or $now > $schedule->stoptime) {
        unset($selected[$banner->id]);
    } else {
        if ($adrotate_config['stats'] == 1 and $banner->tracker == "Y") {
            $stat = adrotate_stats($banner->id, $schedule->starttime, $schedule->stoptime);
            if ($stat['clicks'] >= $schedule->maxclicks and $schedule->maxclicks > 0) {
                unset($selected[$banner->id]);
            }
            if ($stat['impressions'] >= $schedule->maximpressions and $schedule->maximpressions > 0) {
                unset($selected[$banner->id]);
            }
        }
    }
    return $selected;
}
Example #4
0
				<th width="7%"><center><?php 
    _e('CTR', 'adrotate');
    ?>
</center></th>
			<?php 
}
?>
		</tr>
		</thead>
		<tbody>
	<?php 
if ($activebanners) {
    $class = '';
    foreach ($activebanners as $banner) {
        $stats = adrotate_stats($banner['id']);
        $stats_today = adrotate_stats($banner['id'], adrotate_date_start('day'));
        $grouplist = adrotate_ad_is_in_groups($banner['id']);
        $ctr = adrotate_ctr($stats['clicks'], $stats['impressions']);
        if ($adrotate_debug['publisher'] == true) {
            echo "<tr><td>&nbsp;</td><td><strong>[DEBUG]</strong></td><td colspan='9'><pre>";
            echo "Ad Specs: <pre>";
            print_r($banner);
            echo "</pre>";
            echo "Stats: <pre>";
            print_r($stats);
            echo "</pre>";
            echo "Stats today: <pre>";
            print_r($stats_today);
            echo "</pre></td></tr>";
        }
        if ($class != 'alternate') {
?>
</center></th>
				<th width="5%"><center><?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>&nbsp;</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';
		<th width="20%"><?php 
    _e('Visible from', 'adrotate');
    ?>
</th>
		<th width="20%"><?php 
    _e('Visible until', 'adrotate');
    ?>
</th>
	</tr>
	</thead>
	
	<tbody>
<?php 
    foreach ($adverts['active'] as $ad) {
        $stats = adrotate_stats($ad['id']);
        $stats_today = adrotate_stats($ad['id'], adrotate_date_start('day'));
        $grouplist = adrotate_ad_is_in_groups($ad['id']);
        $ctr = adrotate_ctr($stats['clicks'], $stats['impressions']);
        $class = 'adrotate_active';
        if ($ad['type'] == '2days') {
            $class = ' adrotate_error';
        }
        if ($ad['type'] == '7days') {
            $class = ' adrotate_error';
        }
        if ($ad['type'] == 'expired') {
            $class = ' adrotate_urgent';
        }
        ?>

	    <tr id='banner-<?php 
function adrotate_export_stats()
{
    global $wpdb;
    if (wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_ads') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_groups') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_advertiser') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_global')) {
        $id = $type = $month = $year = $adstats = '';
        $id = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_id'], "\t\n "), ENT_QUOTES));
        $type = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_type'], "\t\n "), ENT_QUOTES));
        $month = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_month'], "\t\n "), ENT_QUOTES));
        $year = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_year'], "\t\n "), ENT_QUOTES));
        $csv_emails = trim($_POST['adrotate_export_addresses']);
        if (strlen($csv_emails) > 0) {
            $csv_emails = explode(',', trim($csv_emails));
            foreach ($csv_emails as $csv_email) {
                $csv_email = strip_tags(htmlspecialchars(trim($csv_email), ENT_QUOTES));
                if (strlen($csv_email) > 0) {
                    if (preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}\$/i", $csv_email)) {
                        $clean_advertiser_email[] = $csv_email;
                    }
                }
            }
            $emails = array_unique(array_slice($clean_advertiser_email, 0, 3));
        } else {
            $emails = array();
        }
        $emailcount = count($emails);
        if ($month == 0) {
            $from = mktime(0, 0, 0, 1, 1, $year);
            $until = mktime(0, 0, 0, 12, 31, $year);
        } else {
            $from = mktime(0, 0, 0, $month, 1, $year);
            $until = mktime(0, 0, 0, $month + 1, 0, $year);
        }
        $now = time();
        $from_name = date_i18n("M-d-Y", $from);
        $until_name = date_i18n("M-d-Y", $until);
        $generated = array("Generated on " . date_i18n("M d Y, H:i"));
        if ($type == "single" or $type == "group" or $type == "global") {
            if ($type == "single") {
                $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE (`thetime` >= '" . $from . "' AND `thetime` <= '" . $until . "') AND `ad` = %d GROUP BY `thetime` ASC;", $id), ARRAY_A);
                $title = $wpdb->get_var($wpdb->prepare("SELECT `title` FROM `{$wpdb->prefix}adrotate` WHERE `id` = %d;", $id));
                $filename = "Single-ad ID" . $id . " - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
                $topic = array("Report for ad '" . $title . "'");
                $period = array("Period - From: " . $from_name . " Until: " . $until_name);
                $keys = array("Day", "Clicks", "Impressions");
            }
            if ($type == "group") {
                $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE (`thetime` >= '" . $from . "' AND `thetime` <= '" . $until . "') AND  `group` = %d GROUP BY `thetime` ASC;", $id), ARRAY_A);
                $title = $wpdb->get_var($wpdb->prepare("SELECT `name` FROM `{$wpdb->prefix}adrotate_groups` WHERE `id` = %d;", $id));
                $filename = "Ad Group ID" . $id . " - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
                $topic = array("Report for group '" . $title . "'");
                $period = array("Period - From: " . $from_name . " Until: " . $until_name);
                $keys = array("Day", "Clicks", "Impressions");
            }
            if ($type == "global") {
                $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE `thetime` >= %d AND `thetime` <= %d GROUP BY `thetime` ASC;", $from, $until), ARRAY_A);
                $filename = "Global report - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
                $topic = array("Global report");
                $period = array("Period - From: " . $from_name . " Until: " . $until_name);
                $keys = array("Day", "Clicks", "Impressions");
            }
            $x = 0;
            foreach ($ads as $ad) {
                // Prevent gaps in display
                if ($ad['impressions'] == 0) {
                    $ad['impressions'] = 0;
                }
                if ($ad['clicks'] == 0) {
                    $ad['clicks'] = 0;
                }
                // Build array
                $adstats[$x]['day'] = date_i18n("M d Y", $ad['thetime']);
                $adstats[$x]['clicks'] = $ad['clicks'];
                $adstats[$x]['impressions'] = $ad['impressions'];
                $x++;
            }
        }
        if ($type == "advertiser") {
            // Global advertiser stats
            $ads = $wpdb->get_results($wpdb->prepare("SELECT `ad` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `group` = 0 AND `user` = %d ORDER BY `ad` ASC;", $id));
            $x = 0;
            foreach ($ads as $ad) {
                $title = $wpdb->get_var("SELECT `title` FROM `{$wpdb->prefix}adrotate` WHERE `id` = '" . $ad->ad . "';");
                $startshow = $endshow = 0;
                $startshow = $wpdb->get_var("SELECT `starttime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $ad->ad . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `starttime` ASC LIMIT 1;");
                $endshow = $wpdb->get_var("SELECT `stoptime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $ad->ad . "' AND  `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
                $username = $wpdb->get_var($wpdb->prepare("SELECT `display_name` FROM `{$wpdb->users}`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `{$wpdb->users}`.`ID` = `user` AND `ad` = %d ORDER BY `user_nicename` ASC;", $id));
                $stat = adrotate_stats($ad->ad);
                // Prevent gaps in display
                if ($stat['impressions'] == 0 and $stat['clicks'] == 0) {
                    $ctr = "0";
                } else {
                    $ctr = round(100 / $stat['impressions'] * $stat['clicks'], 2);
                }
                // Build array
                $adstats[$x]['title'] = $title;
                $adstats[$x]['id'] = $ad->ad;
                $adstats[$x]['startshow'] = date_i18n("M d Y", $startshow);
                $adstats[$x]['endshow'] = date_i18n("M d Y", $endshow);
                $adstats[$x]['clicks'] = $stat['clicks'];
                $adstats[$x]['impressions'] = $stat['impressions'];
                $adstats[$x]['ctr'] = $ctr;
                $x++;
            }
            $filename = "Advertiser - " . $username . " - export.csv";
            $topic = array("Advertiser report for " . $username);
            $period = array("Period - Not Applicable");
            $keys = array("Title", "Ad ID", "First visibility", "Last visibility", "Clicks", "Impressions", "CTR (%)");
        }
        if ($type == "advertiser-single") {
            // Single advertiser stats
            $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE (`thetime` >= '{$from}' AND `thetime` <= '{$until}') AND `ad` = %d GROUP BY `thetime` ASC;", $id), ARRAY_A);
            $title = $wpdb->get_var($wpdb->prepare("SELECT `title` FROM `{$wpdb->prefix}adrotate` WHERE `id` = %d;", $id));
            $username = $wpdb->get_var($wpdb->prepare("SELECT `display_name` FROM `{$wpdb->users}`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `{$wpdb->users}`.`ID` = `user` AND `ad` = %d ORDER BY `user_nicename` ASC;", $id));
            $filename = "Single-ad ID" . $id . " - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
            $topic = array("Advertiser report for " . $username . " for ad '" . $title . "'");
            $period = array("Period - From: " . $from_name . " Until: " . $until_name);
            $keys = array("Day", "Clicks", "Impressions");
            $x = 0;
            foreach ($ads as $ad) {
                // Prevent gaps in display
                if ($ad['impressions'] == 0) {
                    $ad['impressions'] = 0;
                }
                if ($ad['clicks'] == 0) {
                    $ad['clicks'] = 0;
                }
                // Build array
                $adstats[$x]['day'] = date_i18n("M d Y", $ad['thetime']);
                $adstats[$x]['clicks'] = $ad['clicks'];
                $adstats[$x]['impressions'] = $ad['impressions'];
                $x++;
            }
        }
        if ($adstats) {
            if (!file_exists(WP_CONTENT_DIR . '/reports/')) {
                mkdir(WP_CONTENT_DIR . '/reports/', 0755);
            }
            $fp = fopen(WP_CONTENT_DIR . '/reports/' . $filename, 'w');
            if ($fp) {
                fputcsv($fp, $topic);
                fputcsv($fp, $period);
                fputcsv($fp, $generated);
                fputcsv($fp, $keys);
                foreach ($adstats as $stat) {
                    fputcsv($fp, $stat);
                }
                fclose($fp);
                if ($emailcount > 0) {
                    $attachments = array(WP_CONTENT_DIR . '/reports/' . $filename);
                    $siteurl = get_option('siteurl');
                    $email = get_option('admin_email');
                    $headers = "MIME-Version: 1.0\r\n" . "From: AdRotate Plugin <" . $email . ">\r\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\r\n";
                    $subject = __('[AdRotate] CSV Report!', 'adrotate-pro');
                    $message = "<p>" . __('Hello', 'adrotate-pro') . ",</p>";
                    $message .= "<p>" . __('Attached in this email you will find the exported CSV file you generated on ', 'adrotate-pro') . " {$siteurl}.</p>";
                    $message .= "<p>" . __('Have a nice day!', 'adrotate-pro') . "<br />";
                    $message .= __('Your AdRotate Notifier', 'adrotate-pro') . "<br />";
                    $message .= "https://ajdg.solutions/products/adrotate-for-wordpress/</p>";
                    wp_mail($emails, $subject, $message, $headers, $attachments);
                    if ($type == "single") {
                        adrotate_return('adrotate-ads', 212, array('view' => 'report', 'ad' => $id));
                    }
                    if ($type == "group") {
                        adrotate_return('adrotate-groups', 212, array('view' => 'report', 'group' => $id));
                    }
                    if ($type == "global") {
                        adrotate_return('adrotate-ads', 212, array('view' => 'fullreport'));
                    }
                    if ($type == "advertiser") {
                        adrotate_return('adrotate-advertiser', 303);
                    }
                    if ($type == "advertiser-single") {
                        adrotate_return('adrotate-advertiser', 303, array('view' => 'report', 'ad' => $id));
                    }
                    exit;
                }
                if ($type == "single") {
                    adrotate_return('adrotate-ads', 215, array('view' => 'report', 'ad' => $id, 'file' => $filename));
                }
                if ($type == "group") {
                    adrotate_return('adrotate-groups', 215, array('view' => 'report', 'group' => $id, 'file' => $filename));
                }
                if ($type == "global") {
                    adrotate_return('adrotate-ads', 215, array('view' => 'fullreport', 'file' => $filename));
                }
                if ($type == "advertiser") {
                    adrotate_return('adrotate-advertiser', 215, array('file' => $filename));
                }
                if ($type == "advertiser-single") {
                    adrotate_return('adrotate-advertiser', 215, array('view' => 'report', 'ad' => $id, 'file' => $filename));
                }
                exit;
            } else {
                if ($type == "single") {
                    adrotate_return('adrotate-ads', 507, array('view' => 'report', 'ad' => $id));
                }
                if ($type == "group") {
                    adrotate_return('adrotate-groups', 507, array('view' => 'report', 'group' => $id));
                }
                if ($type == "global") {
                    adrotate_return('adrotate-ads', 507, array('view' => 'fullreport'));
                }
                if ($type == "advertiser") {
                    adrotate_return('adrotate-advertiser', 507);
                }
                if ($type == "advertiser-single") {
                    adrotate_return('adrotate-advertiser', 507, array('view' => 'report', 'ad' => $id));
                }
            }
        } else {
            if ($type == "single") {
                adrotate_return('adrotate-ads', 503, array('view' => 'report', 'ad' => $id));
            }
            if ($type == "group") {
                adrotate_return('adrotate-groups', 503, array('view' => 'report', 'group' => $id));
            }
            if ($type == "global") {
                adrotate_return('adrotate-ads', 503, array('view' => 'fullreport'));
            }
            if ($type == "advertiser") {
                adrotate_return('adrotate-advertiser', 503);
            }
            if ($type == "advertiser-single") {
                adrotate_return('adrotate-advertiser', 503, array('view' => 'report', 'ad' => $id));
            }
        }
    } else {
        adrotate_nonce_error();
        exit;
    }
}
Example #8
0
    ?>
</center></th>
	        <th><center><?php 
    _e('Max Impressions', 'adrotate-pro');
    ?>
 / <?php 
    _e('Used', 'adrotate-pro');
    ?>
</center></th>
		</tr>
		</thead>

		<tbody>
		<?php 
    foreach ($schedules as $schedule) {
        $stats_schedule = adrotate_stats($banner->id, $schedule->starttime, $schedule->stoptime);
        if ($schedule->maxclicks == 0) {
            $schedule->maxclicks = 'unlimited';
        }
        if ($schedule->maximpressions == 0) {
            $schedule->maximpressions = 'unlimited';
        }
        ?>
      	<tr id='schedule-<?php 
        echo $schedule->id;
        ?>
'>
	        <td><?php 
        echo date_i18n("F d, Y - H:i", $schedule->starttime);
        ?>
</td>
/* ------------------------------------------------------------------------------------
*  COPYRIGHT AND TRADEMARK NOTICE
*  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');
?>
Example #10
0
</center></th>
		<?php 
}
?>
		<th width="17%"><?php 
_e('Contact publisher', 'adrotate-pro');
?>
</th>
	</tr>
	</thead>
	
	<tbody>
<?php 
foreach ($disabledbanners as $ad) {
    if ($adrotate_config['stats'] == 1) {
        $stat = adrotate_stats($ad['id']);
        $ctr = adrotate_ctr($stat['clicks'], $stat['impressions']);
    }
    $wpnonceaction = 'adrotate_email_advertiser_' . $ad['id'];
    $nonce = wp_create_nonce($wpnonceaction);
    $class = 'alternate' != $class ? 'alternate' : '';
    ?>
	    <tr id='banner-<?php 
    echo $ad['id'];
    ?>
' class='<?php 
    echo $class;
    ?>
'>
			<td><center><?php 
    echo $ad['id'];
function adrotate_filter_schedule($selected, $banner)
{
    global $wpdb, $adrotate_config, $adrotate_debug;
    $now = adrotate_now();
    $day = date('D', $now);
    $hour = date('Hi', $now);
    if ($adrotate_debug['general'] == true) {
        echo "<p><strong>[DEBUG][adrotate_filter_schedule()] Filtering banner</strong><pre>";
        print_r($banner->id);
        echo "</pre></p>";
    }
    // Get schedules for advert
    $schedules = $wpdb->get_results("SELECT `{$wpdb->prefix}adrotate_schedule`.* FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` AND `ad` = {$banner->id} ORDER BY `starttime` ASC;");
    $current = array();
    foreach ($schedules as $schedule) {
        if ($adrotate_debug['general'] == true) {
            echo "<p><strong>[DEBUG][adrotate_filter_schedule] Ad " . $banner->id . " - Schedule (id: " . $schedule->id . ")</strong><pre>";
            echo "<br />Start: " . $schedule->starttime . " (" . date("F j, Y, g:i a", $schedule->starttime) . ")";
            echo "<br />End: " . $schedule->stoptime . " (" . date("F j, Y, g:i a", $schedule->stoptime) . ")";
            echo "<br />Impression Spread: " . $schedule->spread . " (Max " . $schedule->dayimpressions . " per day)";
            echo "<br />Show on: Mon " . $schedule->day_mon . ", Tue " . $schedule->day_tue . ", Wed " . $schedule->day_wed . ", Thu " . $schedule->day_thu . ", Fri " . $schedule->day_fri . ", Sat " . $schedule->day_sat . ", Sun " . $schedule->day_sun;
            echo "<br />Show between: " . $schedule->daystarttime . " and " . $schedule->daystoptime . " (Current: " . $hour . ")";
            echo "</pre></p>";
        }
        if ($schedule->starttime > $now or $schedule->stoptime < $now) {
            $current[] = 0;
        } else {
            if ($schedule->day_mon != 'Y' and $day == 'Mon' or $schedule->day_tue != 'Y' and $day == 'Tue' or $schedule->day_wed != 'Y' and $day == 'Wed' or $schedule->day_thu != 'Y' and $day == 'Thu' or $schedule->day_fri != 'Y' and $day == 'Fri' or $schedule->day_sat != 'Y' and $day == 'Sat' or $schedule->day_sun != 'Y' and $day == 'Sun') {
                $current[] = 0;
            } else {
                if (($schedule->daystarttime > 0 or $schedule->daystoptime > 0) and ($schedule->daystarttime > $hour or $schedule->daystoptime < $hour)) {
                    $current[] = 0;
                } else {
                    $current[] = 1;
                    if ($adrotate_config['stats'] == 1 and $banner->tracker == 'Y') {
                        $stat = adrotate_stats($banner->id, $schedule->starttime, $schedule->stoptime, 1);
                        if ($stat['clicks'] >= $schedule->maxclicks and $schedule->maxclicks > 0) {
                            unset($selected[$banner->id]);
                        }
                        if ($schedule->spread == 'Y' && $stat['day'] >= $schedule->dayimpressions) {
                            unset($selected[$banner->id]);
                        } else {
                            if ($stat['impressions'] >= $schedule->maximpressions and $schedule->maximpressions > 0) {
                                unset($selected[$banner->id]);
                            }
                        }
                    }
                }
            }
        }
    }
    // Remove advert from array if all schedules are false (0)
    if (!in_array(1, $current)) {
        unset($selected[$banner->id]);
    }
    unset($current, $schedules, $day, $hour, $daystart, $daystop);
    return $selected;
}
Example #12
0
<?php

/* ------------------------------------------------------------------------------------
*  COPYRIGHT AND TRADEMARK NOTICE
*  Copyright 2008-2015 Arnan de Gans. All Rights Reserved.
*  ADROTATE is a 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);
// Get Click Through Rate
$ctr = adrotate_ctr($stats['clicks'], $stats['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');
?>
 '<?php 
echo $banner->title;
Example #13
0
		<?php 
}
?>
		<th width="17%"><?php 
_e('Contact publisher', 'adrotate-pro');
?>
</th>
	</tr>
	</thead>
	
	<tbody>
<?php 
foreach ($activebanners as $ad) {
    if ($adrotate_config['stats'] == 1) {
        $stats = adrotate_stats($ad['id']);
        $stats_today = adrotate_stats($ad['id'], $today);
        $ctr = adrotate_ctr($stats['clicks'], $stats['impressions']);
    }
    $wpnonceaction = 'adrotate_email_advertiser_' . $ad['id'];
    $nonce = wp_create_nonce($wpnonceaction);
    $errorclass = $class = '';
    if ('alternate' == $class) {
        $class = 'alternate';
    } else {
        $class = '';
    }
    if ($ad['type'] == '2days') {
        $errorclass = ' row_error';
    }
    if ($ad['type'] == '7days') {
        $errorclass = ' row_error';
                <th width="5%"><?php 
_e('Month', 'add-rotate-email-addon');
?>
</th>
	            <th width="5%"><?php 
_e('Action', 'add-rotate-email-addon');
?>
</th>
	        </tr>
	        </thead>
	        <tbody>
	        <?php 
if ($activebanners1) {
    foreach ($activebanners1 as $banner) {
        $stats = adrotate_stats($banner['id']);
        $stats_today = adrotate_stats($banner['id'], $today);
        $ctr = adrotate_ctr($stats['clicks'], $stats['impressions']);
        $id = $banner['id'];
        $ad_title = $banner['title'];
        $tracker = $banner['tracker'];
        $users = Ad_Rotate_Email_Addon_Admin::find_user($id);
        foreach ($users as $user) {
            $user_name = $user['user_login'];
            $display_name = $user['display_name'];
        }
        ?>
	                <tr>

		                <th class="check-column"><input type="checkbox" name="bannercheck[]" value="<?php 
        echo $id;
        ?>