Ejemplo n.º 1
0
*  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.
------------------------------------------------------------------------------------ */
/**
 * Override this template by copying it to yourtheme/adrotate-summary.php
 *
 * @version     1.0
 */
global $current_user;
$adverts = adrotate_load_adverts($current_user->ID);
// Summary stats
$summary = adrotate_prepare_advertiser_report($current_user->ID, $adverts['active']);
?>

<table class="widefat" style="margin-top: .5em">					
	<tbody>
    <tr>
		<td width="15%"><?php 
_e('General', 'adrotate');
?>
</td>
		<td><?php 
echo $summary['ad_amount'];
?>
 <?php 
_e('ads, sharing a total of', 'adrotate');
?>
Ejemplo n.º 2
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 
}