Skip to content

Commit

Permalink
5.15.5
Browse files Browse the repository at this point in the history
* [update] WordPress media uploader only lists and allows relevant files
* [fix] Text indicating unfiltered html suggesting the wrong setting
  • Loading branch information
adegans committed Oct 28, 2024
1 parent fa5bd3d commit ff187c7
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 52 deletions.
38 changes: 19 additions & 19 deletions adrotate-statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
Name: adrotate_get_stats
Purpose: Quick check for the latest number of clicks and impressions
-------------------------------------------------------------*/
function adrotate_get_stats($ad, $when = 0, $until = 0) {
function adrotate_get_stats($ad_id, $when = 0, $until = 0) {
global $wpdb;

$stats = $wpdb->get_row("SELECT SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = {$ad} AND `thetime` >= {$when} AND `thetime` <= {$until} GROUP BY `ad` ORDER BY `ad` ASC;", ARRAY_A);
$stats = $wpdb->get_row("SELECT SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = {$ad_id} AND `thetime` >= {$when} AND `thetime` <= {$until} GROUP BY `ad` ORDER BY `ad` ASC;", ARRAY_A);

if(empty($stats['clicks'])) $stats['clicks'] = '0';
if(empty($stats['impressions'])) $stats['impressions'] = '0';
Expand Down Expand Up @@ -62,7 +62,7 @@ function adrotate_date_start($what) {
Name: adrotate_count_impression
Purpose: Count Impressions where needed
-------------------------------------------------------------*/
function adrotate_count_impression($ad, $group = 0, $blog_id = 0) {
function adrotate_count_impression($ad_id, $group_id = 0, $blog_id = 0) {
global $wpdb, $adrotate_config;

$now = current_time('timestamp');
Expand All @@ -77,16 +77,16 @@ function adrotate_count_impression($ad, $group = 0, $blog_id = 0) {
$impression_timer = $now - $adrotate_config['impression_timer'];

if($remote_ip != 'unknown' AND !empty($remote_ip)) {
$saved_timer = $wpdb->get_var($wpdb->prepare("SELECT `timer` FROM `{$wpdb->prefix}adrotate_tracker` WHERE `ipaddress` = '%s' AND `stat` = 'i' AND `bannerid` = %d ORDER BY `timer` DESC LIMIT 1;", $remote_ip, $ad));
$saved_timer = $wpdb->get_var($wpdb->prepare("SELECT `timer` FROM `{$wpdb->prefix}adrotate_tracker` WHERE `ipaddress` = '%s' AND `stat` = 'i' AND `bannerid` = %d ORDER BY `timer` DESC LIMIT 1;", $remote_ip, $ad_id));
if($saved_timer < $impression_timer AND adrotate_is_human()) {
$stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad, $group));
$stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad_id, $group_id));
if($stats > 0) {
$wpdb->query("UPDATE `{$wpdb->prefix}adrotate_stats` SET `impressions` = `impressions` + 1 WHERE `id` = {$stats};");
} else {
$wpdb->insert($wpdb->prefix.'adrotate_stats', array('ad' => $ad, 'group' => $group, 'thetime' => $today, 'clicks' => 0, 'impressions' => 1));
$wpdb->insert($wpdb->prefix.'adrotate_stats', array('ad' => $ad_id, 'group' => $group_id, 'thetime' => $today, 'clicks' => 0, 'impressions' => 1));
}

$wpdb->insert($wpdb->prefix."adrotate_tracker", array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad, 'stat' => 'i'));
$wpdb->insert($wpdb->prefix."adrotate_tracker", array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad_id, 'stat' => 'i'));
}
}

Expand All @@ -109,9 +109,9 @@ function adrotate_impression_callback() {

$meta = esc_attr($meta);
// Don't use $impression_timer - It's for impressions used in javascript
list($ad, $group, $blog_id, $impression_timer) = explode(",", $meta, 4);
if(is_numeric($ad) AND is_numeric($group) AND is_numeric($blog_id)) {
adrotate_count_impression($ad, $group, $blog_id);
list($ad_id, $group_id, $blog_id, $impression_timer) = explode(",", $meta, 4);
if(is_numeric($ad_id) AND is_numeric($group_id) AND is_numeric($blog_id)) {
adrotate_count_impression($ad_id, $group_id, $blog_id);
}

die();
Expand All @@ -133,9 +133,9 @@ function adrotate_click_callback() {

$meta = esc_attr($meta);
// Don't use $impression_timer - It's for impressions used in javascript
list($ad, $group, $blog_id, $impression_timer) = explode(",", $meta, 4);
list($ad_id, $group_id, $blog_id, $impression_timer) = explode(",", $meta, 4);

if(is_numeric($ad) AND is_numeric($group) AND is_numeric($blog_id)) {
if(is_numeric($ad_id) AND is_numeric($group_id) AND is_numeric($blog_id)) {
if($blog_id > 0 AND adrotate_is_networked()) {
$current_blog = $wpdb->blogid;
switch_to_blog($blog_id);
Expand All @@ -148,29 +148,29 @@ function adrotate_click_callback() {
$today = adrotate_date_start('day');
$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));
$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_id));
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));
$stats = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `{$wpdb->prefix}adrotate_stats` WHERE `ad` = %d AND `group` = %d AND `thetime` = {$today};", $ad_id, $group_id));
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_stats', array('ad' => $ad_id, 'group' => $group_id, 'thetime' => $today, 'clicks' => 1, 'impressions' => 1));
}

$wpdb->insert($wpdb->prefix.'adrotate_tracker', array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad, 'stat' => 'c'));
$wpdb->insert($wpdb->prefix.'adrotate_tracker', array('ipaddress' => $remote_ip, 'timer' => $now, 'bannerid' => $ad_id, 'stat' => 'c'));
}

// Advertising budget
$wpdb->query("UPDATE `{$wpdb->prefix}adrotate` SET `budget` = `budget` - `crate` WHERE `id` = {$ad} AND `crate` > 0;");
$wpdb->query("UPDATE `{$wpdb->prefix}adrotate` SET `budget` = `budget` - `crate` WHERE `id` = {$ad_id} AND `crate` > 0;");
}

if($blog_id > 0 AND adrotate_is_networked()) {
switch_to_blog($current_blog);
}

unset($remote_ip, $track, $meta, $ad, $group, $remote, $banner);
unset($remote_ip, $track, $meta, $ad_id, $group_id, $remote, $banner);
}

die();
}
?>
?>
6 changes: 3 additions & 3 deletions adrotate.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/*
Plugin Name: AdRotate Banner Manager
Plugin URI: https://ajdg.solutions/product/adrotate-banner-manager/?mtm_campaign=adrotate&mtm_keyword=plugin_info
Plugin URI: https://ajdg.solutions/product/adrotate-banner-manager/
Author: Arnan de Gans
Author URI: https://www.arnan.me/?mtm_campaign=adrotate&mtm_keyword=plugin_info
Author URI: https://www.arnan.me/
Description: Manage all your adverts with all the features you need while keeping things simple.
Text Domain: adrotate
Version: 5.13.4
Version: 5.13.5
License: GPLv3
*/

Expand Down
24 changes: 12 additions & 12 deletions dashboard/settings/maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<form name="settings" id="post" method="post" action="admin.php?page=adrotate-settings&tab=maintenance">
<?php wp_nonce_field('adrotate_settings','adrotate_nonce_settings'); ?>
<h2><?php _e("Maintenance", 'adrotate'); ?></h2>
<table class="form-table">
<table class="form-table">
<tr>
<th valign="top"><?php _e("Check adverts", 'adrotate'); ?></th>
<td>
Expand All @@ -25,7 +25,7 @@
</table>

<h3><?php _e("Status and Versions", 'adrotate'); ?></h3>
<table class="form-table">
<table class="form-table">
<tr>
<th valign="top"><?php _e("Current status of adverts", 'adrotate'); ?></th>
<td colspan="3"><?php _e("Normal", 'adrotate'); ?>: <?php echo $advert_status['normal']; ?>, <?php _e("Error", 'adrotate'); ?>: <?php echo $advert_status['error']; ?>, <?php _e("Expired", 'adrotate'); ?>: <?php echo $advert_status['expired']; ?>, <?php _e("Expires Soon", 'adrotate'); ?>: <?php echo $advert_status['expiressoon']; ?>, <?php _e("Unknown", 'adrotate'); ?>: <?php echo $advert_status['unknown']; ?>.</td>
Expand All @@ -52,10 +52,10 @@
<th width="15%"><?php _e("Unfiltered HTML", 'adrotate'); ?></th>
<td colspan="3">
<?php
if(defined('DISALLOW_UNFILTERED_HTML') && !DISALLOW_UNFILTERED_HTML) {
if(defined('DISALLOW_UNFILTERED_HTML') && !DISALLOW_UNFILTERED_HTML) {
echo "<span style=\"color:#009900;\">".__("Allowed", 'adrotate')."</span>";
} else {
echo "<span style=\"color:#CC2900;\">".__("Your website's current setup does not allow for unfiltered code to be used in adverts.", 'adrotate')."</span><br />".__("This is required for javascript adverts to work. To enable this you need to set the DISALLOW_UNFILTERED_HTML definition to 'true' in your wp-config.php file.", 'adrotate')." <a href=\"https://ipstack.com/product\" target=\"_blank\">".__("More info", 'adrotate')."</a>";
echo "<span style=\"color:#CC2900;\">".__("Your website's current setup does not allow for unfiltered code to be used in adverts.", 'adrotate')."</span><br />".__("This is required for javascript adverts to work. To enable this you need to set the DISALLOW_UNFILTERED_HTML definition to 'false' in your wp-config.php file.", 'adrotate')." <a href=\"https://ipstack.com/product\" target=\"_blank\">".__("More info", 'adrotate')."</a>";
}
?>
</td>
Expand All @@ -79,25 +79,25 @@

<h2><?php _e("Internal Versions", 'adrotate'); ?></h2>
<span class="description"><?php _e("Unless you experience database issues or a warning shows below, these numbers are not really relevant for troubleshooting. Support may ask for them to verify your database status.", 'adrotate'); ?></span>
<table class="form-table">
<table class="form-table">
<tr>
<th width="15%" valign="top"><?php _e("AdRotate version", 'adrotate'); ?></th>
<td>
<?php
<?php
echo __("Current:", 'adrotate')."<span style=\"color:#009900;\">".$adrotate_version['current']."</span>";
if($adrotate_version['current'] != ADROTATE_VERSION) {
echo "<span style=\"color:#CC2900;\">".__("Should be:", 'adrotate')." ".ADROTATE_VERSION."</span>";
}
if($adrotate_version['current'] != ADROTATE_VERSION) {
echo "<span style=\"color:#CC2900;\">".__("Should be:", 'adrotate')." ".ADROTATE_VERSION."</span>";
}
?>
<br /><?php echo __("Previous:", 'adrotate')." ".$adrotate_version['previous']; ?>
</td>
<th width="15%" valign="top"><?php _e("Database version", 'adrotate'); ?></th>
<td>
<?php
<?php
echo __("Current:", 'adrotate')."<span style=\"color:#009900;\">".$adrotate_db_version['current']."</span>";
if($adrotate_db_version['current'] != ADROTATE_DB_VERSION) {
if($adrotate_db_version['current'] != ADROTATE_DB_VERSION) {
echo "<span style=\"color:#CC2900;\">".__("Should be:", 'adrotate')." ".ADROTATE_DB_VERSION."</span>";
}
}
?>
<br /><?php echo __("Previous:", 'adrotate')." ".$adrotate_db_version['previous']; ?>
</td>
Expand Down
4 changes: 3 additions & 1 deletion library/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
.stats_large { display: block; margin-bottom: 10px; margin-top: 10px; text-align: center; font-weight: bold; }
.number_large { margin: 20px; font-size: 28px; }

.adrotate_inline_error { margin-left:10px; padding:5px; background-color:#c00; color:#fff; }

/* Ad previews */
.preview-wrapper { padding:0; width:50%; height:100px; border:3px solid; border-radius:10px; text-align:center; }
.preview-inner { padding:20px 10px; display:inline-block; text-align:center; }
Expand Down Expand Up @@ -97,4 +99,4 @@
.ui-datepicker-unselectable .ui-state-default { background: #f4f4f4; color: #b4b3b3; }
.ui-datepicker-calendar td:first-child .ui-state-active { width: 29px; margin-left: 0; }
.ui-datepicker-calendar td:last-child .ui-state-active { width: 29px; margin-right: 0; }
.ui-datepicker-calendar tr:last-child .ui-state-active { height: 29px; margin-bottom: 0; }
.ui-datepicker-calendar tr:last-child .ui-state-active { height: 29px; margin-bottom: 0; }
29 changes: 24 additions & 5 deletions library/uploader-hook.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/*
use the Media Uploader from WordPress
Version: 1.0
Original code: Arnan de Gans
Copyright: (c) 2020 Arnan de Gans
Version: 1.1
Copyright: (c) 2020-2024 Arnan de Gans
*/
jQuery(document).ready(function(){
var custom_uploader;
Expand All @@ -12,11 +11,31 @@ jQuery(document).ready(function(){
custom_uploader.open();
return;
}
custom_uploader = wp.media.frames.file_frame = wp.media({title: 'Choose Banner',button: {text: 'Choose Banner'},multiple: false});
custom_uploader = wp.media.frames.file_frame = wp.media({
title: 'Choose Banner',
button: {text: 'Choose Banner'},
multiple: false,
library: { type: 'image/jpg, image/jpeg, image/gif, image/png, image/svg, image/webp, text/html, text/htm' }
});
custom_uploader.on('select', function() {
attachment = custom_uploader.state().get('selection').first().toJSON();
// Check if selected mediafile is of wrong file type
allowedFiles = ['image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/svg', 'image/webp', 'text/html', 'text/htm'];
if(!allowedFiles.includes(attachment.mime)) {
// Create error element
const err_el = document.createElement('span');
err_el.classList.add('adrotate_inline_error');
err_el.innerHTML = 'File (' + attachment.mime + ') is not supported for ads.';
// Check if error message does not exist yet and add it if it doesn't
if(!document.querySelector('.adrotate-wrong-filetype')) {
jQuery('#adrotate_image_button').after(err_el);
jQuery('#adrotate_image').val('');
}
return;
}
jQuery('.adrotate-wrong-filetype').remove();
jQuery('#adrotate_image').val(attachment.url);
});
custom_uploader.open();
});
});
});
28 changes: 16 additions & 12 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
=== AdRotate Banner Manager - The only ad manager you'll need ===
Contributors: adegans
Donate link: https://www.arnan.me/donate.html
Tags: ads, banner manager, adsense, affiliate, banners
Stable tag: 5.13.5
Requires at least: 4.9
Tested up to: 6.6.1
Tested up to: 6.7
CP requires at least: 1.0
CP tested up to: 2.1.1
CP tested up to: 2.2
Requires PHP: 7.4
Stable tag: 5.13.4
Donate link: https://ajdg.solutions/product/adrotate-pro-single/
Tags: ads, banner manager, adsense, affiliate, banners
License: GPLv3

Advertising made easy. Manage all your ads including Google Ads, Amazon banners and many more from your dashboard.
Expand Down Expand Up @@ -101,11 +101,15 @@ Installing AdRotate is super easy.
- A new menu called "AdRotate" appears in the WordPress navigation.
- From this menu you'll handle everything related to **AdRotate Banner Manager**.

For more detailed instructions check out the [installation steps](https://ajdg.solutions/support/adrotate-manuals/installing-adrotate-on-your-website/?mtm_campaign=adrotate&mtm_kwd=readme) on the AdRotate website.
For more detailed instructions check out the [installation steps](https://ajdg.solutions/support/adrotate-manuals/installing-adrotate-on-your-website/) on the AdRotate website.

== Changelog ==

For the full changelog check out the [development page](https://ajdg.solutions/support/adrotate-development/?mtm_campaign=adrotate&mtm_kwd=readme).
For the full changelog check out the [development page](https://ajdg.solutions/support/adrotate-development/).

= AdRotate 5.13.5 =
* [update] WordPress media uploader only lists and allows relevant files
* [fix] Text indicating unfiltered html suggesting the wrong setting

= AdRotate 5.13.4 =
* [fix] Image selection not kept when using the advert generator
Expand Down Expand Up @@ -195,7 +199,7 @@ For the full changelog check out the [development page](https://ajdg.solutions/s
* [new] Automated trigger after updates to finish the update
* [removed] wp_cache_set() for stats

Be a Pro and get [AdRotate Professional](https://ajdg.solutions/product-category/adrotate-pro/?mtm_campaign=adrotate&mtm_kwd=readme) to support the plugin and get more features!
Be a Pro and get [AdRotate Professional](https://ajdg.solutions/product-category/adrotate-pro/) to support the plugin and get more features!

== Upgrade Notice ==

Expand All @@ -204,11 +208,11 @@ Enjoy this update with the latest tweaks and improvements for AdRotate Banner Ma
== Frequently Asked Questions ==

= How do I use AdRotate? =
Take a look at the [user guides](https://ajdg.solutions/support/adrotate-manuals/?mtm_campaign=adrotate&mtm_kwd=readme).
Take a look at the [user guides](https://ajdg.solutions/support/adrotate-manuals/).
You can also post your questions on the [forum](https://ajdg.solutions/forums/forum/adrotate-for-wordpress/).

= I need help with this plugin =
The best place to ask your question is on my [support forum](https://ajdg.solutions/forums/forum/adrotate-for-wordpress/?mtm_campaign=adrotate&mtm_kwd=readme).
The best place to ask your question is on my [support forum](https://ajdg.solutions/forums/forum/adrotate-for-wordpress/).
The forum is checked daily and most questions are answered within hours.

= Does AdRotate offer click tracking? =
Expand All @@ -222,11 +226,11 @@ Most ads, from any ad server, work without special tricks or tweaks.
Yes!

= This is cool, do you have more plugins? =
Yep, check out my website [AJdG Solutions](https://ajdg.solutions/?mtm_campaign=adrotate&mtm_kwd=readme)
Yep, check out my website [AJdG Solutions](https://ajdg.solutions/)

= Why do some dashboard notifications look so ugly =
If a dashboard notification misses its layout or looks out of shape try clearing your browser cache.
Some ad blockers block parts of the AdRotate dashboard, check out this page to make an exception for your website in adblockers - [Whitelist your site](https://ajdg.solutions/support/adrotate-manuals/configure-adblockers-for-your-own-website/?mtm_campaign=adrotate&mtm_kwd=readme).
Some ad blockers block parts of the AdRotate dashboard, check out this page to make an exception for your website in adblockers - [Whitelist your site](https://ajdg.solutions/support/adrotate-manuals/configure-adblockers-for-your-own-website/).

= Is AdRotate compatible with Yoast SEO or other SEO plugins? =
Yes, Yoast SEO, All-in-One SEO pack and all other SEO plugins work fine with AdRotate.
Expand Down

0 comments on commit ff187c7

Please sign in to comment.