コード例 #1
0
function adrotate_prepare_fullreport()
{
    global $wpdb;
    $today = adrotate_date_start('day');
    $stats['banners'] = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "adrotate` WHERE `type` = 'active';");
    $stats['tracker'] = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "adrotate` WHERE `tracker` = 'Y' AND `type` = 'active';");
    $stats['clicks'] = $wpdb->get_var("SELECT SUM(`clicks`) as `clicks` FROM `" . $wpdb->prefix . "adrotate_stats`;");
    $stats['impressions'] = $wpdb->get_var("SELECT SUM(`impressions`) as `impressions` FROM `" . $wpdb->prefix . "adrotate_stats`;");
    if (!$stats['banners']) {
        $stats['banners'] = 0;
    }
    if (!$stats['tracker']) {
        $stats['tracker'] = 0;
    }
    if (!$stats['clicks']) {
        $stats['clicks'] = 0;
    }
    if (!$stats['impressions']) {
        $stats['impressions'] = 0;
    }
    return $stats;
}
コード例 #2
0
function adrotate_click_callback()
{
    define('DONOTCACHEPAGE', true);
    define('DONOTCACHEDB', true);
    define('DONOTCACHCEOBJECT', true);
    global $wpdb, $adrotate_config, $adrotate_debug;
    $meta = $_POST['track'];
    if ($adrotate_debug['track'] != true) {
        $meta = base64_decode($meta);
    }
    $meta = esc_attr($meta);
    list($ad, $group, $blog_id, $impression_timer) = explode(",", $meta, 4);
    if (is_numeric($ad) and is_numeric($group) and is_numeric($blog_id)) {
        if ($adrotate_config['enable_loggedin_clicks'] == 'Y' and is_user_logged_in() or !is_user_logged_in()) {
            $remote_ip = adrotate_get_remote_ip();
            if (adrotate_is_bot() and $remote_ip != "unknown" and !empty($remote_ip)) {
                $now = adrotate_now();
                $today = adrotate_date_start('day');
                if ($adrotate_debug['timers'] == true) {
                    $click_timer = $now;
                } else {
                    $click_timer = $now - $adrotate_config['click_timer'];
                }
                $saved_timer = $wpdb->get_var($wpdb->prepare("SELECT `timer` FROM `" . $wpdb->prefix . "adrotate_tracker` WHERE `ipaddress` = '%s' AND `stat` = 'c' AND `bannerid` = %d ORDER BY `timer` DESC LIMIT 1;", $remote_ip, $ad));
                if ($saved_timer < $click_timer) {
                    $stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . $wpdb->prefix . "adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad, $group));
                    if ($stats > 0) {
                        $wpdb->query("UPDATE `" . $wpdb->prefix . "adrotate_stats` SET `clicks` = `clicks` + 1 WHERE `id` = {$stats};");
                    } else {
                        $wpdb->insert($wpdb->prefix . 'adrotate_stats', array('ad' => $ad, 'group' => $group, 'thetime' => $today, 'clicks' => 1, 'impressions' => 1));
                    }
                    $wpdb->insert($wpdb->prefix . 'adrotate_tracker', array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad, 'stat' => 'c', 'useragent' => $useragent, 'country' => '', 'city' => ''));
                }
            }
        }
        unset($remote_ip, $track, $meta, $ad, $group, $remote, $banner);
    }
    wp_die();
}
コード例 #3
0
ファイル: adrotate.php プロジェクト: vanlong200880/tmdt
function adrotate_manage_schedules()
{
    global $wpdb;
    $now = adrotate_now();
    $today = adrotate_date_start('day');
    $in2days = $now + 172800;
    $in7days = $now + 604800;
    $in84days = $now + 7257600;
    ?>
	<div class="wrap">
		<h1><?php 
    _e('Schedule Management available in AdRotate Pro', 'adrotate');
    ?>
</h1>

		<div class="tablenav">
			<div class="alignleft actions">
				<strong><?php 
    _e('Manage', 'adrotate');
    ?>
</strong> | 
				<strong><?php 
    _e('Add New', 'adrotate');
    ?>
</strong>
			</div>
		</div>

		<h3><?php 
    _e('Manage Schedules', 'adrotate');
    ?>
</h3>
		<p><?php 
    _e('Schedule management and multiple schedules per advert is available in AdRotate Pro.', 'adrotate');
    ?>
 <a href="admin.php?page=adrotate-pro"><?php 
    _e('More information', 'adrotate');
    ?>
</a>.</p>
		
		<?php 
    wp_nonce_field('adrotate_bulk_schedules', 'adrotate_nonce');
    ?>
	
		<div class="tablenav top">
			<div class="alignleft actions">
				<select name="adrotate_action" id="cat" class="postform" disabled>
			        <option value=""><?php 
    _e('Bulk Actions', 'adrotate');
    ?>
</option>
				</select> <input type="submit" id="post-action-submit" name="adrotate_action_submit" value="<?php 
    _e('Go', 'adrotate');
    ?>
" class="button-secondary" disabled />
			</div>	
			<br class="clear" />
		</div>
		
		<table class="widefat" style="margin-top: .5em">
			<thead>
			<tr>
				<td scope="col" class="manage-column column-cb check-column"><input type="checkbox" disabled/></td>
				<th width="4%"><center><?php 
    _e('ID', 'adrotate');
    ?>
</center></th>
				<th width="20%"><?php 
    _e('Start', 'adrotate');
    ?>
 / <?php 
    _e('End', 'adrotate');
    ?>
</th>
		        <th width="4%"><center><?php 
    _e('Ads', 'adrotate');
    ?>
</center></th>
				<th>&nbsp;</th>
		        <th width="15%"><center><?php 
    _e('Max Impressions', 'adrotate');
    ?>
</center></th>
		        <th width="10%"><center><?php 
    _e('Max Clicks', 'adrotate');
    ?>
</center></th>
			</tr>
			</thead>
			<tbody>
		<?php 
    $schedules = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "adrotate_schedule` WHERE `name` != '' ORDER BY `id` ASC;");
    if ($schedules) {
        $class = '';
        foreach ($schedules as $schedule) {
            $schedulesmeta = $wpdb->get_results("SELECT `ad` FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `group` = 0 AND `user` = 0 AND `schedule` = " . $schedule->id . ";");
            if ($schedule->maxclicks == 0) {
                $schedule->maxclicks = '&infin;';
            }
            if ($schedule->maximpressions == 0) {
                $schedule->maximpressions = '&infin;';
            }
            $class != 'alternate' ? $class = 'alternate' : ($class = '');
            if ($schedule->stoptime < $in2days) {
                $class = 'row_urgent';
            }
            if ($schedule->stoptime < $now) {
                $class = 'row_inactive';
            }
            ?>
			    <tr id='adrotateindex' class='<?php 
            echo $class;
            ?>
'>
					<th class="check-column"><input type="checkbox" name="schedulecheck[]" value="" disabled /></th>
					<td><center><?php 
            echo $schedule->id;
            ?>
</center></td>
					<td><?php 
            echo date_i18n("F d, Y H:i", $schedule->starttime);
            ?>
<br /><span style="color: <?php 
            echo adrotate_prepare_color($schedule->stoptime);
            ?>
;"><?php 
            echo date_i18n("F d, Y H:i", $schedule->stoptime);
            ?>
</span></td>
			        <td><center><?php 
            echo count($schedulesmeta);
            ?>
</center></td>
					<td><?php 
            echo stripslashes(html_entity_decode($schedule->name));
            ?>
</td>
			        <td><center><?php 
            echo $schedule->maximpressions;
            ?>
</center></td>
			        <td><center><?php 
            echo $schedule->maxclicks;
            ?>
</center></td>
				</tr>
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
			<tr id='no-schedules'>
				<th class="check-column">&nbsp;</th>
				<td colspan="7"><em><?php 
        _e('No schedules created yet!', 'adrotate');
        ?>
</em></td>
			</tr>
			<?php 
    }
    ?>
			</tbody>
		</table>
		<center><?php 
    _e('Easily manage your schedules from here with AdRotate Pro.', 'adrotate');
    ?>
 <a href="admin.php?page=adrotate-pro"><?php 
    _e('Upgrade today!', 'adrotate');
    ?>
</a></center>

		<p><center>
			<span style="border: 1px solid #c00; height: 12px; width: 12px; background-color: #ffebe8">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php 
    _e("Expires soon.", "adrotate");
    ?>
			&nbsp;&nbsp;&nbsp;&nbsp;<span style="border: 1px solid #466f82; height: 12px; width: 12px; background-color: #8dcede">&nbsp;&nbsp;&nbsp;&nbsp;</span> <?php 
    _e("Has expired.", "adrotate");
    ?>
		</center></p>

		<br class="clear" />

		<?php 
    adrotate_credits();
    ?>

		<br class="clear" />
	</div>
<?php 
}
コード例 #4
0
ファイル: adverts-main.php プロジェクト: simonsays88/costa
				<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') {
コード例 #5
0
ファイル: adrotate-setup.php プロジェクト: simonsays88/costa
function adrotate_activate_setup() {
	global $wpdb, $userdata;

	if(version_compare(PHP_VERSION, '5.3.0', '<') == -1) { 
		deactivate_plugins(plugin_basename('adrotate/adrotate.php'));
		wp_die('AdRotate 3.10.8 and newer requires PHP 5.3 or higher. Your server reports version '.PHP_VERSION.'. Contact your hosting provider about upgrading your server!<br /><a href="'. get_option('siteurl').'/wp-admin/plugins.php">Back to dashboard</a>.'); 
		return; 
	} else {
		if(!current_user_can('activate_plugins')) {
			deactivate_plugins(plugin_basename('adrotate/adrotate.php'));
			wp_die('You do not have appropriate access to activate this plugin! Contact your administrator!<br /><a href="'. get_option('siteurl').'/wp-admin/plugins.php">Back to dashboard</a>.'); 
			return; 
		} else {
			// Set defaults for internal versions
			add_option('adrotate_db_version', array('current' => ADROTATE_DB_VERSION, 'previous' => ''));
			add_option('adrotate_version', array('current' => ADROTATE_VERSION, 'previous' => ''));

			// Set default settings and values
			add_option('adrotate_config', array());
			add_option('adrotate_notifications', array());
			add_option('adrotate_crawlers', array());
			add_option('adrotate_db_timer', date('U'));
			add_option('adrotate_debug', array('general' => false, 'publisher' => false, 'timers' => false, 'track' => false));
			add_option('adrotate_advert_status', array('error' => 0, 'expired' => 0, 'expiressoon' => 0, 'normal' => 0, 'total' => 0));
			add_option('adrotate_geo_required', 0);
			add_option('adrotate_geo_requests', 0);
			add_option('adrotate_responsive_required', 0);
			add_option('adrotate_dynamic_required', 0);
			add_option('adrotate_hide_banner', adrotate_now());
			add_option('adrotate_hide_review', adrotate_now());
	
			// Install new database
			adrotate_database_install();
			adrotate_dummy_data();
			adrotate_check_config();
	
			// Set the capabilities for the administrator
			$role = get_role('administrator');		
			$role->add_cap("adrotate_ad_manage");
			$role->add_cap("adrotate_ad_delete");
			$role->add_cap("adrotate_group_manage");
			$role->add_cap("adrotate_group_delete");
	
			// Switch additional roles off
			if(is_object(get_role('adrotate_advertiser'))) {
				adrotate_prepare_roles('remove');
			}
	
			// Set up some schedules
			$firstrun = adrotate_date_start('day');
			if(!wp_next_scheduled('adrotate_clean_trackerdata')) { // Periodically clean trackerdata
				wp_schedule_event($firstrun, 'twicedaily', 'adrotate_clean_trackerdata');
			}
	
			if(!wp_next_scheduled('adrotate_evaluate_ads')) {// Periodically check ads
				wp_schedule_event($firstrun + 1800, 'twicedaily', 'adrotate_evaluate_ads');
			}
	
			// Attempt to make the some folders
			if(!is_dir(ABSPATH.'wp-content/banners')) mkdir(ABSPATH.'/wp-content/banners', 0755);
			if(!is_dir(ABSPATH.'wp-content/reports')) mkdir(ABSPATH.'/wp-content/reports', 0755);
		}
	}
}
コード例 #6
0
		<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 
コード例 #7
0
function adrotate_advertiser()
{
    global $wpdb, $current_user, $adrotate_config, $adrotate_debug;
    get_currentuserinfo();
    $status = $view = $ad_edit_id = $request = $request_id = '';
    if (isset($_GET['status'])) {
        $status = esc_attr($_GET['status']);
    }
    if (isset($_GET['view'])) {
        $view = esc_attr($_GET['view']);
    }
    if (isset($_GET['ad'])) {
        $ad_edit_id = esc_attr($_GET['ad']);
    }
    if (isset($_GET['file'])) {
        $filename = esc_attr($_GET['file']);
    }
    if (isset($_GET['request'])) {
        $request = esc_attr($_GET['request']);
    }
    if (isset($_GET['id'])) {
        $request_id = esc_attr($_GET['id']);
    }
    $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);
    ?>
	<div class="wrap">
	  	<h1><?php 
    _e('Advertiser', 'adrotate-pro');
    ?>
</h1>

		<?php 
    if ($status > 0) {
        adrotate_status($status, array('file' => $filename));
    }
    ?>

		<div class="tablenav">
			<div class="alignleft actions">
				<a class="row-title" href="<?php 
    echo admin_url('/admin.php?page=adrotate-advertiser');
    ?>
"><?php 
    _e('Manage', 'adrotate-pro');
    ?>
</a>
				<?php 
    if ($adrotate_config['enable_editing'] == 'Y') {
        ?>
				 | <a class="row-title" href="<?php 
        echo admin_url('/admin.php?page=adrotate-advertiser&view=addnew');
        ?>
"><?php 
        _e('Add New', 'adrotate-pro');
        ?>
</a> 
				<?php 
    }
    ?>
			</div>
		</div>

		<?php 
    $wpnonceaction = 'adrotate_email_advertiser_' . $request_id;
    if ($view == "") {
        $ads = $wpdb->get_results($wpdb->prepare("SELECT `ad` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `group` = 0 AND `user` = %d ORDER BY `ad` ASC;", $current_user->ID));
        if ($ads) {
            $activebanners = $queuebanners = $disabledbanners = false;
            foreach ($ads as $ad) {
                $banner = $wpdb->get_row("SELECT `id`, `title`, `type`, `mobile`, `tablet`, `budget`, `crate`, `irate` FROM `{$wpdb->prefix}adrotate` WHERE (`type` = 'active' OR `type` = '2days' OR `type` = '7days' OR `type` = 'disabled' OR `type` = 'error' OR `type` = 'a_error' OR `type` = 'expired' OR `type` = 'queue' OR `type` = 'reject') AND `id` = '" . $ad->ad . "';");
                // Skip if no ad
                if (!$banner) {
                    continue;
                }
                $starttime = $stoptime = 0;
                $starttime = $wpdb->get_var("SELECT `starttime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $banner->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` = '" . $banner->id . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
                $type = $banner->type;
                if ($type == 'active' and $stoptime <= $in7days) {
                    $type = '7days';
                }
                if ($type == 'active' and $stoptime <= $in2days) {
                    $type = '2days';
                }
                if ($type == 'active' and $stoptime <= $now) {
                    $type = 'expired';
                }
                if ($type == 'active' or $type == '2days' or $type == '7days' or $type == 'expired') {
                    $activebanners[$banner->id] = array('id' => $banner->id, 'title' => $banner->title, 'type' => $type, 'mobile' => $banner->mobile, 'tablet' => $banner->tablet, 'firstactive' => $starttime, 'lastactive' => $stoptime, 'budget' => $banner->budget, 'crate' => $banner->crate, 'irate' => $banner->irate);
                }
                if ($type == 'disabled') {
                    $disabledbanners[$banner->id] = array('id' => $banner->id, 'title' => $banner->title, 'type' => $type);
                }
                if ($type == 'queue' or $type == 'reject' or $type == 'error' or $type == 'a_error') {
                    $queuebanners[$banner->id] = array('id' => $banner->id, 'title' => $banner->title, 'type' => $type, 'mobile' => $banner->mobile, 'tablet' => $banner->tablet, 'budget' => $banner->budget, 'crate' => $banner->crate, 'irate' => $banner->irate);
                }
            }
            // Show active ads, if any
            if ($activebanners) {
                include "dashboard/advertiser/main.php";
            }
            // Show disabled ads, if any
            if ($disabledbanners) {
                include "dashboard/advertiser/main-disabled.php";
            }
            // Show queued ads, if any
            if ($queuebanners) {
                include "dashboard/advertiser/main-queue.php";
            }
            if ($adrotate_config['stats'] == 1) {
                // Gather data for summary report
                $summary = adrotate_prepare_advertiser_report($current_user->ID, $activebanners);
                include "dashboard/advertiser/main-summary.php";
            }
        } else {
            ?>
				<table class="widefat" style="margin-top: .5em">
					<thead>
						<tr>
							<th><?php 
            _e('Notice', 'adrotate-pro');
            ?>
</th>
						</tr>
					</thead>
					<tbody>
					    <tr>
							<td><?php 
            _e('No ads for user.', 'adrotate-pro');
            ?>
</td>
						</tr>
					</tbody>
				</table>
				<?php 
        }
    } else {
        if ($view == "addnew" or $view == "edit") {
            include "dashboard/advertiser/edit.php";
        } else {
            if ($view == "report") {
                include "dashboard/advertiser/report.php";
            } else {
                if ($view == "message") {
                    if (wp_verify_nonce($_REQUEST['_wpnonce'], $wpnonceaction)) {
                        include "dashboard/advertiser/message.php";
                    } else {
                        adrotate_nonce_error();
                        exit;
                    }
                }
            }
        }
    }
    ?>
		<br class="clear" />

		<?php 
    adrotate_user_notice();
    ?>

		<br class="clear" />
	</div>
<?php 
}
コード例 #8
0
}
/*
 *  Send Bulk mails to user request condition check
 */
if (isset($_POST['adrotate_email_nonce']) && wp_verify_nonce($_POST['adrotate_email_nonce'], 'adrotate_email_ad_active')) {
    if (isset($_POST['adrotate_action']) && $_POST['adrotate_action'] != '' && isset($_POST['bannercheck']) && isset($_POST['dsp_report_gen_month']) && $_POST['dsp_report_gen_month'] != '') {
        $month = $_POST['dsp_report_gen_month'];
        $dsp_email1 = new Ad_Rotate_Email_Addon_Send_Email();
        foreach ($_POST['bannercheck'] as $ad_id) {
            $dsp_email1->send_email($ad_id, $month);
        }
    }
}
global $wpdb, $current_user, $userdata, $adrotate_config, $adrotate_debug;
$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);
?>
	<div class="wrap">
		<h2><?php 
コード例 #9
0
function adrotate_load_adverts($user_id)
{
    global $wpdb;
    $now = adrotate_now();
    $today = adrotate_date_start('day');
    $in2days = $now + 172800;
    $in7days = $now + 604800;
    $in84days = $now + 7257600;
    $ads = $wpdb->get_results($wpdb->prepare("SELECT `ad` FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `group` = 0 AND `user` = %d ORDER BY `ad` ASC;", $user_id));
    if ($ads) {
        $adverts = array('active' => array(), 'disabled' => array(), 'queued' => array());
        foreach ($ads as $ad) {
            $banner = $wpdb->get_row("SELECT `id`, `title`, `type`, `tracker` FROM `" . $wpdb->prefix . "adrotate` WHERE (`type` = 'active' OR `type` = '2days' OR `type` = '7days' OR `type` = 'disabled' OR `type` = 'error' OR `type` = 'a_error' OR `type` = 'expired' OR `type` = 'queue' OR `type` = 'reject') AND `id` = '" . $ad->ad . "';");
            // Skip if no ad
            if (!$banner) {
                continue;
            }
            $starttime = $stoptime = 0;
            $starttime = $wpdb->get_var("SELECT `starttime` FROM `" . $wpdb->prefix . "adrotate_schedule`, `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = '" . $banner->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` = '" . $banner->id . "' AND `schedule` = `" . $wpdb->prefix . "adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
            $type = $banner->type;
            if ($type == 'active' and $stoptime <= $in7days) {
                $type = '7days';
            }
            if ($type == 'active' and $stoptime <= $in2days) {
                $type = '2days';
            }
            if ($type == 'active' and $stoptime <= $now) {
                $type = 'expired';
            }
            if ($type == 'active' or $type == '2days' or $type == '7days' or $type == 'expired') {
                $adverts['active'][$banner->id] = array('id' => $banner->id, 'title' => stripslashes(html_entity_decode($banner->title)), 'type' => $type, 'tracker' => $banner->tracker, 'firstactive' => $starttime, 'lastactive' => $stoptime);
            }
            if ($type == 'disabled') {
                $adverts['disabled'][$banner->id] = array('id' => $banner->id, 'title' => stripslashes(html_entity_decode($banner->title)), 'type' => $type);
            }
            if ($type == 'queue' or $type == 'reject' or $type == 'error' or $type == 'a_error') {
                $adverts['queued'][$banner->id] = array('id' => $banner->id, 'title' => stripslashes(html_entity_decode($banner->title)), 'type' => $type);
            }
        }
        return $adverts;
    }
}