function adrotate_manage() { global $wpdb, $userdata; $message = $_GET['message']; $magic_id = $_GET['magic_id']; $cancel = $_GET['cancel']; if (isset($_POST['adrotate_order'])) { $order = $_POST['adrotate_order']; } else { $order = 'thetime ASC'; } if ($cancel and $magic_id > 0) { adrotate_delete($magic_id, 'banner'); } $groups = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "adrotate_groups` ORDER BY `id`"); ?> <div class="wrap"> <h2>Manage Banners</h2> <?php if ($message == 'created') { ?> <div id="message" class="updated fade"><p>Banner <strong>created</strong>.</p></div> <?php } else { if ($message == 'updated') { ?> <div id="message" class="updated fade"><p>Banner <strong>updated</strong>.</p></div> <?php } else { if ($message == 'deleted') { ?> <div id="message" class="updated fade"><p>Banner(s) <strong>deleted</strong>.</p></div> <?php } else { if ($message == 'moved') { ?> <div id="message" class="updated fade"><p>Banner(s) <strong>moved</strong>.</p></div> <?php } else { if ($message == 'reset') { ?> <div id="message" class="updated fade"><p>Banner(s) statistics <strong>reset</strong>.</p></div> <?php } else { if ($message == 'renew') { ?> <div id="message" class="updated fade"><p>Banner(s) <strong>renewed</strong>.</p></div> <?php } else { if ($message == 'deactivate') { ?> <div id="message" class="updated fade"><p>Banner(s) <strong>deactivated</strong>.</p></div> <?php } else { if ($message == 'activate') { ?> <div id="message" class="updated fade"><p>Banner(s) <strong>activated</strong>.</p></div> <?php } else { if ($message == 'no_access') { ?> <div id="message" class="updated fade"><p>Action prohibited.</p></div> <?php } } } } } } } } } ?> <form name="banners" id="post" method="post" action="admin.php?page=adrotate"> <div class="tablenav"> <div class="alignleft actions"> <select name='adrotate_action' id='cat' class='postform' > <option disabled>Bulk Actions</option> <option value="deactivate">Deactivate</option> <option value="activate">Activate</option> <option value="delete">Delete</option> <option value="resetmultiple">Reset stats</option> <option value="renewmultiple-31536000">Renew for 1 year</option> <option value="renewmultiple-2592000">Renew for 30 days</option> <option value="renewmultiple-5184000">Renew for 180 days</option> <?php if ($groups) { ?> <option disabled>Move selection to category</option> <?php foreach ($groups as $group) { ?> <option value="move-<?php echo $group->id; ?> "><?php echo $group->id; ?> - <?php echo $group->name; ?> </option> <?php } ?> <?php } ?> </select> <input type="submit" id="post-action-submit" value="Go" class="button-secondary" /> Sort by <select name='adrotate_order' id='cat' class='postform' > <option value="startshow ASC" <?php if ($order == "startshow ASC") { echo 'selected'; } ?> >start date (ascending)</option> <option value="startshow DESC" <?php if ($order == "startshow DESC") { echo 'selected'; } ?> >start date (descending)</option> <option value="endshow ASC" <?php if ($order == "endshow ASC") { echo 'selected'; } ?> >end date (ascending)</option> <option value="endshow DESC" <?php if ($order == "endshow DESC") { echo 'selected'; } ?> >end date (descending)</option> <option value="ID ASC" <?php if ($order == "ID ASC") { echo 'selected'; } ?> >ID</option> <option value="ID DESC" <?php if ($order == "ID DESC") { echo 'selected'; } ?> >ID reversed</option> <option value="title ASC" <?php if ($order == "title ASC") { echo 'selected'; } ?> >title (A-Z)</option> <option value="title DESC" <?php if ($order == "title DESC") { echo 'selected'; } ?> >title (Z-A)</option> <option value="clicks ASC" <?php if ($order == "clicks ASC") { echo 'selected'; } ?> >clicks (A-Z)</option> <option value="clicks DESC" <?php if ($order == "clicks DESC") { echo 'selected'; } ?> >clicks (Z-A)</option> </select> <input type="submit" id="post-query-submit" value="Sort" class="button-secondary" /> </div> <br class="clear" /> </div> <table class="widefat" style="margin-top: .5em"> <thead> <tr> <th scope="col" class="check-column"> </th> <th scope="col" width="2%"><center>ID</center></th> <th scope="col" width="10%">Show from</th> <th scope="col" width="10%">Show until</th> <th scope="col" width="5%"><center>Active</center></th> <th scope="col" width="5%"><center>How</center></th> <th scope="col" width="15%">Group</th> <th scope="col">Title</th> <th scope="col" width="5%"><center>Shown</center></th> <th scope="col" width="5%"><center>Clicks</center></th> <th scope="col" width="8%"><center>CTR</center></th> </tr> </thead> <tbody> <?php if (adrotate_mysql_table_exists($wpdb->prefix . 'adrotate')) { $now = current_time('timestamp'); $in2days = $now + 172800; $banners = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "adrotate` WHERE `magic` < 2 ORDER BY " . $order); if ($banners) { foreach ($banners as $banner) { $group = $wpdb->get_row("SELECT `name` FROM `" . $wpdb->prefix . "adrotate_groups` WHERE `id` = '" . $banner->group . "'"); $expired = $wpdb->get_var("SELECT `id` FROM `" . $wpdb->prefix . "adrotate` WHERE `id` = {$banner->id} AND `active` = 'yes' AND (`endshow` <= {$now} OR `endshow` <= {$in2days})"); if ($expired == $banner->id) { $expiredclass = ' error'; } else { $expiredclass = ''; } if ($class != 'alternate') { $class = 'alternate'; } else { $class = ''; } ?> <tr id='banner-<?php echo $banner->id; ?> ' class='<?php echo $class . $expiredclass; ?> '> <th scope="row" class="check-column"><input type="checkbox" name="bannercheck[]" value="<?php echo $banner->id; ?> " /></th> <td><center><?php echo $banner->id; ?> </center></td> <td><?php echo date("F d, Y", $banner->startshow); ?> </td> <td><?php echo date("F d, Y", $banner->endshow); ?> </td> <td><center><?php if ($banner->active == "yes") { echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/adrotate/icons/tick.png" title="Active"/>'; } else { echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/adrotate/icons/cross.png" title="In-active"/>'; } ?> </center></td> <?php if ($banner->magic == 1) { ?> <td><img src="<?php echo get_option('siteurl'); ?> /wp-content/plugins/adrotate/icons/wizard.png" title="Wizard"/></td> <?php } else { if ($banner->magic == 0) { ?> <td><img src="<?php echo get_option('siteurl'); ?> /wp-content/plugins/adrotate/icons/manual.png" title="Manual"/></td> <?php } else { ?> <td><center>Error</center></td> <?php } } ?> <?php if ($group->name != '') { ?> <td><?php echo $group->name; ?> </td> <?php } else { ?> <td><span style="font-weight:bold; color:red;">No Group Set!</span></td> <?php } ?> <td><strong><a class="row-title" href="<?php echo get_option('siteurl') . '/wp-admin/admin.php?page=adrotate3&edit_banner=' . $banner->id; ?> " title="Edit"><?php echo stripslashes(html_entity_decode($banner->title)); ?> </a></strong></td> <td><center><?php echo $banner->shown; ?> </center></td> <?php if ($banner->tracker == "Y") { ?> <td><center><?php echo $banner->clicks; ?> </center></td> <?php if ($banner->shown == 0) { $banner->shown = 1; } ?> <td><center><?php echo round(100 / $banner->shown * $banner->clicks, 2); ?> %</center></td> <?php } else { ?> <td colspan="2"><center>N/A</center></td> <?php } ?> </tr> <?php } ?> <?php } else { ?> <tr id='no-id'><td scope="row" colspan="7"><em>No banners yet!</em></td></tr> <?php } } else { ?> <tr id='no-id'><td scope="row" colspan="7"><span style="font-weight: bold; color: #f00;">There was an error locating the main database table for AdRotate. Please deactivate and re-activate AdRotate from the plugin page!!<br />If this does not solve the issue please seek support at <a href="http://forum.at.meandmymac.net">http://forum.at.meandmymac.net</a></span></td></tr> <?php } ?> </tbody> </table> </form> <br class="clear" /> <?php adrotate_credits(); ?> </div> <?php }
function adrotate_request_action() { global $wpdb, $adrotate_config; $banner_ids = $group_ids = ''; if (wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_bulk_ads_active') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_bulk_ads_disable') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_bulk_ads_error') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_bulk_ads_queue') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_bulk_groups')) { if (isset($_POST['bannercheck'])) { $banner_ids = $_POST['bannercheck']; } if (isset($_POST['disabledbannercheck'])) { $banner_ids = $_POST['disabledbannercheck']; } if (isset($_POST['errorbannercheck'])) { $banner_ids = $_POST['errorbannercheck']; } if (isset($_POST['groupcheck'])) { $group_ids = $_POST['groupcheck']; } if (isset($_POST['adrotate_id'])) { $banner_ids = array($_POST['adrotate_id']); } // Determine which kind of action to use if (isset($_POST['adrotate_action'])) { // Default action call $actions = $_POST['adrotate_action']; } else { if (isset($_POST['adrotate_disabled_action'])) { // Disabled ads listing call $actions = $_POST['adrotate_disabled_action']; } else { if (isset($_POST['adrotate_error_action'])) { // Erroneous ads listing call $actions = $_POST['adrotate_error_action']; } } } if (preg_match("/-/", $actions)) { list($action, $specific) = explode("-", $actions); } else { $action = $actions; } if ($banner_ids != '') { $return = 'adrotate-ads'; if ($action == 'export') { if (current_user_can('adrotate_moderate')) { adrotate_export($banner_ids); $result_id = 215; } else { adrotate_return($return, 500); } } foreach ($banner_ids as $banner_id) { if ($action == 'deactivate') { if (current_user_can('adrotate_ad_manage')) { adrotate_active($banner_id, 'deactivate'); $result_id = $banner_id; } else { adrotate_return($return, 500); } } if ($action == 'activate') { if (current_user_can('adrotate_ad_manage')) { adrotate_active($banner_id, 'activate'); $result_id = $banner_id; } else { adrotate_return($return, 500); } } if ($action == 'delete') { if (current_user_can('adrotate_ad_delete')) { adrotate_delete($banner_id, 'banner'); $result_id = $banner_id; } else { adrotate_return($return, 500); } } if ($action == 'reset') { if (current_user_can('adrotate_ad_delete')) { adrotate_reset($banner_id); $result_id = $banner_id; } else { adrotate_return($return, 500); } } if ($action == 'renew') { if (current_user_can('adrotate_ad_manage')) { adrotate_renew($banner_id, $specific); $result_id = $banner_id; } else { adrotate_return($return, 500); } } if ($action == 'weight') { if (current_user_can('adrotate_ad_manage')) { adrotate_weight($banner_id, $specific); $result_id = $banner_id; } else { adrotate_return($return, 500); } } } adrotate_prepare_evaluate_ads(false); } if ($group_ids != '') { $return = 'adrotate-groups'; foreach ($group_ids as $group_id) { if ($action == 'group_delete') { if (current_user_can('adrotate_group_delete')) { adrotate_delete($group_id, 'group'); $result_id = $group_id; } else { adrotate_return($return, 500); } } if ($action == 'group_delete_banners') { if (current_user_can('adrotate_group_delete')) { adrotate_delete($group_id, 'bannergroup'); $result_id = $group_id; } else { adrotate_return($return, 500); } } } } adrotate_return($return, $result_id); } else { adrotate_nonce_error(); exit; } }
function adrotate_request_action() { global $wpdb, $userdata, $adrotate_tracker; if (isset($_POST['bannercheck'])) { $banner_ids = $_POST['bannercheck']; } if (isset($_POST['adrotate_id'])) { $banner_ids = array($_POST['adrotate_id']); } if (isset($_POST['groupcheck'])) { $group_ids = $_POST['groupcheck']; } $actions = $_POST['adrotate_action']; list($action, $specific) = explode("-", $actions); if (current_user_can('manage_options')) { if ($banner_ids != '') { foreach ($banner_ids as $banner_id) { if ($action == 'deactivate') { adrotate_active($banner_id, 'deactivate'); } if ($action == 'activate') { adrotate_active($banner_id, 'activate'); } if ($action == 'delete') { adrotate_delete($banner_id, 'banner'); } if ($action == 'reset' or $action == 'resetmultiple') { adrotate_reset($banner_id); } if ($action == 'renew') { adrotate_renew($banner_id); } if ($action == 'renewmultiple') { adrotate_renew($banner_id, $specific); } if ($action == 'move') { adrotate_move($banner_id, $specific); } } } if ($group_ids != '') { foreach ($group_ids as $group_id) { if ($action == 'group_delete') { adrotate_delete($group_id, 'group'); } if ($action == 'group_delete_banners') { adrotate_delete($group_id, 'bannergroup'); } } } adrotate_return($action, array($banner_id)); } else { adrotate_return('no_access'); } }