Version Description
Enjoy this update with the latest tweaks and improvements for AdRotate for WordPress!
Download this release
Release Info
Developer | adegans |
Plugin | AdRotate Banner Manager |
Version | 5.8.11 |
Comparing to | |
See all releases |
Code changes from version 5.8.10 to 5.8.11
- adrotate-functions.php +29 -35
- adrotate-manage-publisher.php +89 -85
- adrotate.php +2 -2
- readme.txt +1 -1
adrotate-functions.php
CHANGED
@@ -626,11 +626,11 @@ function adrotate_dropdown_folder_contents($base_dir, $extensions = array('jpg',
|
|
626 |
}
|
627 |
|
628 |
/*-------------------------------------------------------------
|
629 |
-
Name:
|
630 |
Purpose: List sub-folder contents for media manager
|
631 |
Since: 4.9
|
632 |
-------------------------------------------------------------*/
|
633 |
-
function
|
634 |
$index = $assets = array();
|
635 |
|
636 |
// Read Banner folder
|
@@ -644,14 +644,14 @@ function adrotate_subfolder_contents($asset_folder, $level = 1) {
|
|
644 |
|
645 |
if(count($assets) > 0) {
|
646 |
$new_level = $level + 1;
|
647 |
-
$extensions = array('jpg', 'jpeg', 'gif', 'png', 'swf', 'flv', 'html', 'htm', 'js');
|
648 |
|
649 |
foreach($assets as $key => $asset) {
|
650 |
$fileinfo = pathinfo($asset);
|
651 |
unset($fileinfo['dirname']);
|
652 |
if(is_dir($asset_folder.'/'.$asset)) { // Read subfolder
|
653 |
if($level <= 2) { // Not to deep
|
654 |
-
$fileinfo['contents'] =
|
655 |
$index[] = $fileinfo;
|
656 |
}
|
657 |
} else { // It's a file
|
@@ -669,61 +669,56 @@ function adrotate_subfolder_contents($asset_folder, $level = 1) {
|
|
669 |
}
|
670 |
|
671 |
/*-------------------------------------------------------------
|
672 |
-
Name:
|
673 |
-
Purpose:
|
674 |
-
Since:
|
675 |
-------------------------------------------------------------*/
|
676 |
-
function
|
677 |
$index = $assets = array();
|
678 |
|
679 |
-
// Read
|
680 |
if($handle = opendir($asset_folder)) {
|
681 |
-
|
682 |
-
if($file != "." AND $file != ".." AND $file != "index.php" AND $file != ".DS_Store") {
|
683 |
-
$assets[] = $file;
|
684 |
-
}
|
685 |
-
}
|
686 |
-
closedir($handle);
|
687 |
-
|
688 |
-
if(count($assets) > 0) {
|
689 |
-
$new_level = $level + 1;
|
690 |
-
$extensions = array('jpg', 'jpeg', 'gif', 'png', 'svg', 'swf', 'flv', 'html', 'htm', 'js');
|
691 |
|
692 |
-
|
|
|
693 |
$fileinfo = pathinfo($asset);
|
694 |
unset($fileinfo['dirname']);
|
695 |
if(is_dir($asset_folder.'/'.$asset)) { // Read subfolder
|
696 |
-
|
697 |
-
|
698 |
-
$
|
699 |
}
|
700 |
} else { // It's a file
|
701 |
-
if(
|
702 |
-
$
|
|
|
|
|
703 |
}
|
704 |
}
|
705 |
unset($fileinfo);
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
}
|
710 |
-
|
711 |
-
return $index;
|
712 |
}
|
713 |
|
714 |
/*-------------------------------------------------------------
|
715 |
Name: adrotate_unlink
|
716 |
-
|
717 |
Purpose: Delete a file or folder from the banners folder
|
718 |
-
Receive: $file
|
719 |
-
Return: boolean
|
720 |
Since: 4.9
|
721 |
-------------------------------------------------------------*/
|
722 |
-
function adrotate_unlink($asset) {
|
723 |
global $adrotate_config;
|
724 |
|
725 |
$access_type = get_filesystem_method();
|
726 |
if($access_type === 'direct') {
|
|
|
|
|
|
|
|
|
|
|
|
|
727 |
$credentials = request_filesystem_credentials(site_url().'/wp-admin/', '', false, false, array());
|
728 |
|
729 |
if(!WP_Filesystem($credentials)) {
|
@@ -732,7 +727,6 @@ function adrotate_unlink($asset) {
|
|
732 |
|
733 |
global $wp_filesystem;
|
734 |
|
735 |
-
$path = WP_CONTENT_DIR."/".$adrotate_config['banner_folder']."/".$asset;
|
736 |
if(!is_dir($path)) { // It's a file
|
737 |
if(unlink($path)) {
|
738 |
return true;
|
626 |
}
|
627 |
|
628 |
/*-------------------------------------------------------------
|
629 |
+
Name: adrotate_mediapage_folder_contents
|
630 |
Purpose: List sub-folder contents for media manager
|
631 |
Since: 4.9
|
632 |
-------------------------------------------------------------*/
|
633 |
+
function adrotate_mediapage_folder_contents($asset_folder, $level = 1) {
|
634 |
$index = $assets = array();
|
635 |
|
636 |
// Read Banner folder
|
644 |
|
645 |
if(count($assets) > 0) {
|
646 |
$new_level = $level + 1;
|
647 |
+
$extensions = array('jpg', 'jpeg', 'gif', 'png', 'svg', 'swf', 'flv', 'html', 'htm', 'js');
|
648 |
|
649 |
foreach($assets as $key => $asset) {
|
650 |
$fileinfo = pathinfo($asset);
|
651 |
unset($fileinfo['dirname']);
|
652 |
if(is_dir($asset_folder.'/'.$asset)) { // Read subfolder
|
653 |
if($level <= 2) { // Not to deep
|
654 |
+
$fileinfo['contents'] = adrotate_mediapage_folder_contents($asset_folder.'/'.$asset, $new_level);
|
655 |
$index[] = $fileinfo;
|
656 |
}
|
657 |
} else { // It's a file
|
669 |
}
|
670 |
|
671 |
/*-------------------------------------------------------------
|
672 |
+
Name: adrotate_clean_folder_contents
|
673 |
+
Purpose: Delete unwanted advert assets after uploading a zip file
|
674 |
+
Since: 5.8.7
|
675 |
-------------------------------------------------------------*/
|
676 |
+
function adrotate_clean_folder_contents($asset_folder) {
|
677 |
$index = $assets = array();
|
678 |
|
679 |
+
// Read asset folder
|
680 |
if($handle = opendir($asset_folder)) {
|
681 |
+
$extensions = array('jpg', 'jpeg', 'gif', 'png', 'svg', 'swf', 'flv', 'html', 'htm', 'js');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
682 |
|
683 |
+
while(false !== ($asset = readdir($handle))) {
|
684 |
+
if($asset != "." AND $asset != "..") {
|
685 |
$fileinfo = pathinfo($asset);
|
686 |
unset($fileinfo['dirname']);
|
687 |
if(is_dir($asset_folder.'/'.$asset)) { // Read subfolder
|
688 |
+
adrotate_clean_folder_contents($asset_folder.'/'.$asset);
|
689 |
+
if(count(scandir($asset_folder.'/'.$asset)) == 2) { // Remove empty folder
|
690 |
+
adrotate_unlink($asset, $asset_folder);
|
691 |
}
|
692 |
} else { // It's a file
|
693 |
+
if(array_key_exists('extension', $fileinfo)) {
|
694 |
+
if(!in_array($fileinfo['extension'], $extensions)) {
|
695 |
+
adrotate_unlink($asset, $asset_folder);
|
696 |
+
}
|
697 |
}
|
698 |
}
|
699 |
unset($fileinfo);
|
700 |
+
}
|
701 |
+
}
|
702 |
+
closedir($handle);
|
703 |
}
|
|
|
|
|
704 |
}
|
705 |
|
706 |
/*-------------------------------------------------------------
|
707 |
Name: adrotate_unlink
|
|
|
708 |
Purpose: Delete a file or folder from the banners folder
|
|
|
|
|
709 |
Since: 4.9
|
710 |
-------------------------------------------------------------*/
|
711 |
+
function adrotate_unlink($asset, $path = '') {
|
712 |
global $adrotate_config;
|
713 |
|
714 |
$access_type = get_filesystem_method();
|
715 |
if($access_type === 'direct') {
|
716 |
+
if($path == "") {
|
717 |
+
$path = WP_CONTENT_DIR."/".$adrotate_config['banner_folder']."/".$asset;
|
718 |
+
} else {
|
719 |
+
$path = $path.'/'.$asset;
|
720 |
+
}
|
721 |
+
|
722 |
$credentials = request_filesystem_credentials(site_url().'/wp-admin/', '', false, false, array());
|
723 |
|
724 |
if(!WP_Filesystem($credentials)) {
|
727 |
|
728 |
global $wp_filesystem;
|
729 |
|
|
|
730 |
if(!is_dir($path)) { // It's a file
|
731 |
if(unlink($path)) {
|
732 |
return true;
|
adrotate-manage-publisher.php
CHANGED
@@ -28,10 +28,10 @@ function adrotate_generate_input() {
|
|
28 |
if(isset($_POST['adrotate_targeturl'])) $targeturl = strip_tags(trim($_POST['adrotate_targeturl'], "\t\n "));
|
29 |
|
30 |
$new_window = '';
|
31 |
-
if(isset($_POST['adrotate_newwindow'])) $new_window = strip_tags(trim($_POST['adrotate_newwindow'], "\t\n "));
|
32 |
|
33 |
$portability = '';
|
34 |
-
if(isset($_POST['adrotate_portability'])) $portability = strip_tags(trim($_POST['adrotate_portability'], "\t\n "));
|
35 |
|
36 |
if(current_user_can('adrotate_ad_manage')) {
|
37 |
if(strlen($portability) == 0) {
|
@@ -43,22 +43,22 @@ function adrotate_generate_input() {
|
|
43 |
} else {
|
44 |
$adwidth = $adheight = '';
|
45 |
}
|
46 |
-
|
47 |
// Open in a new window?
|
48 |
if(isset($new_window) AND strlen($new_window) != 0) {
|
49 |
$new_window = ' target="_blank"';
|
50 |
} else {
|
51 |
$new_window = '';
|
52 |
}
|
53 |
-
|
54 |
// Determine image settings
|
55 |
$imagetype = "dropdown";
|
56 |
$image = WP_CONTENT_URL."/%folder%/".$fullsize_image;
|
57 |
$asset = "<img src=\"%asset%\"".$adwidth.$adheight." />";
|
58 |
-
|
59 |
// Generate code
|
60 |
$bannercode = "<a href=\"".$targeturl."\"".$new_window.">".$asset."</a>";
|
61 |
-
|
62 |
// Save the advert to the DB
|
63 |
$wpdb->update($wpdb->prefix.'adrotate', array('bannercode' => $bannercode, 'imagetype' => $imagetype, 'image' => $image), array('id' => $id));
|
64 |
} else {
|
@@ -82,7 +82,7 @@ function adrotate_generate_input() {
|
|
82 |
/*-------------------------------------------------------------
|
83 |
Name: adrotate_insert_input
|
84 |
Purpose: Prepare input form on saving new or updated banners
|
85 |
-
Since: 0.1
|
86 |
-------------------------------------------------------------*/
|
87 |
function adrotate_insert_input() {
|
88 |
global $wpdb, $adrotate_config;
|
@@ -106,7 +106,7 @@ function adrotate_insert_input() {
|
|
106 |
if(isset($_POST['adrotate_end_date'])) $end_date = strip_tags(trim($_POST['adrotate_end_date'], "\t\n "));
|
107 |
if(isset($_POST['adrotate_end_hour'])) $end_hour = strip_tags(trim($_POST['adrotate_end_hour'], "\t\n "));
|
108 |
if(isset($_POST['adrotate_end_minute'])) $end_minute = strip_tags(trim($_POST['adrotate_end_minute'], "\t\n "));
|
109 |
-
|
110 |
$maxclicks = $maxshown = '';
|
111 |
if(isset($_POST['adrotate_maxclicks'])) $maxclicks = strip_tags(trim($_POST['adrotate_maxclicks'], "\t\n "));
|
112 |
if(isset($_POST['adrotate_maxshown'])) $maxshown = strip_tags(trim($_POST['adrotate_maxshown'], "\t\n "));
|
@@ -117,25 +117,25 @@ function adrotate_insert_input() {
|
|
117 |
if(isset($_POST['adrotate_image'])) $image_field = strip_tags(trim($_POST['adrotate_image'], "\t\n "));
|
118 |
if(isset($_POST['adrotate_image_dropdown'])) $image_dropdown = strip_tags(trim($_POST['adrotate_image_dropdown'], "\t\n "));
|
119 |
if(isset($_POST['adrotate_tracker'])) $tracker = strip_tags(trim($_POST['adrotate_tracker'], "\t\n "));
|
120 |
-
|
121 |
// Misc variables
|
122 |
$type = '';
|
123 |
$groups = array();
|
124 |
if(isset($_POST['groupselect'])) $groups = $_POST['groupselect'];
|
125 |
if(isset($_POST['adrotate_type'])) $type = strip_tags(trim($_POST['adrotate_type'], "\t\n "));
|
126 |
-
|
127 |
-
|
128 |
if(current_user_can('adrotate_ad_manage')) {
|
129 |
if(strlen($title) < 1) {
|
130 |
$title = 'Ad '.$id;
|
131 |
}
|
132 |
-
|
133 |
// Clean up bannercode
|
134 |
if(preg_match("/%ID%/", $bannercode)) $bannercode = str_replace('%ID%', '%id%', $bannercode);
|
135 |
if(preg_match("/%IMAGE%/", $bannercode)) $bannercode = str_replace('%IMAGE%', '%image%', $bannercode);
|
136 |
if(preg_match("/%TITLE%/", $bannercode)) $bannercode = str_replace('%TITLE%', '%title%', $bannercode);
|
137 |
if(preg_match("/%RANDOM%/", $bannercode)) $bannercode = str_replace('%RANDOM%', '%random%', $bannercode);
|
138 |
-
|
139 |
// Sort out start dates
|
140 |
if(strlen($start_date) > 0) {
|
141 |
list($start_day, $start_month, $start_year) = explode('-', $start_date); // dd/mm/yyyy
|
@@ -145,13 +145,13 @@ function adrotate_insert_input() {
|
|
145 |
|
146 |
if(($start_year > 0 AND $start_month > 0 AND $start_day > 0) AND strlen($start_hour) == 0) $start_hour = '00';
|
147 |
if(($start_year > 0 AND $start_month > 0 AND $start_day > 0) AND strlen($start_minute) == 0) $start_minute = '00';
|
148 |
-
|
149 |
if($start_month > 0 AND $start_day > 0 AND $start_year > 0) {
|
150 |
$start_date = mktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year);
|
151 |
} else {
|
152 |
$start_date = 0;
|
153 |
}
|
154 |
-
|
155 |
// Sort out end dates
|
156 |
if(strlen($end_date) > 0) {
|
157 |
list($end_day, $end_month, $end_year) = explode('-', $end_date); // dd/mm/yyyy
|
@@ -161,23 +161,23 @@ function adrotate_insert_input() {
|
|
161 |
|
162 |
if(($end_year > 0 AND $end_month > 0 AND $end_day > 0) AND strlen($end_hour) == 0) $end_hour = '00';
|
163 |
if(($end_year > 0 AND $end_month > 0 AND $end_day > 0) AND strlen($end_minute) == 0) $end_minute = '00';
|
164 |
-
|
165 |
if($end_month > 0 AND $end_day > 0 AND $end_year > 0) {
|
166 |
$end_date = mktime($end_hour, $end_minute, 0, $end_month, $end_day, $end_year);
|
167 |
} else {
|
168 |
$end_date = 0;
|
169 |
}
|
170 |
-
|
171 |
// Enddate is too early, reset to default
|
172 |
if($end_date <= $start_date) $end_date = $start_date + 7257600; // 84 days (12 weeks)
|
173 |
-
|
174 |
// Sort out click and impressions restrictions
|
175 |
if(strlen($maxclicks) < 1 OR !is_numeric($maxclicks)) $maxclicks = 0;
|
176 |
if(strlen($maxshown) < 1 OR !is_numeric($maxshown)) $maxshown = 0;
|
177 |
-
|
178 |
if(isset($tracker) AND strlen($tracker) != 0) $tracker = 'Y';
|
179 |
else $tracker = 'N';
|
180 |
-
|
181 |
// Determine image settings ($image_field has priority!)
|
182 |
if(strlen($image_field) > 1) {
|
183 |
$imagetype = "field";
|
@@ -189,10 +189,10 @@ function adrotate_insert_input() {
|
|
189 |
$imagetype = "";
|
190 |
$image = "";
|
191 |
}
|
192 |
-
|
193 |
// Save schedule for new ads or update the existing one
|
194 |
if($type != 'empty') {
|
195 |
-
$wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}adrotate_schedule` WHERE `id` IN (SELECT `schedule` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `schedule` != %d AND `schedule` > 0 AND `ad` = %d AND `group` = 0 AND `user` = 0);", $schedule_id, $id));
|
196 |
}
|
197 |
$wpdb->update($wpdb->prefix.'adrotate_schedule', array('starttime' => $start_date, 'stoptime' => $end_date, 'maxclicks' => $maxclicks, 'maximpressions' => $maxshown), array('id' => $schedule_id));
|
198 |
|
@@ -205,33 +205,33 @@ function adrotate_insert_input() {
|
|
205 |
foreach($groupmeta as $meta) {
|
206 |
$group_array[] = $meta->group;
|
207 |
}
|
208 |
-
|
209 |
// Add new groups to this ad
|
210 |
$insert = array_diff($groups, $group_array);
|
211 |
foreach($insert as &$value) {
|
212 |
$wpdb->insert($wpdb->prefix.'adrotate_linkmeta', array('ad' => $id, 'group' => $value, 'user' => 0, 'schedule' => 0));
|
213 |
}
|
214 |
unset($value);
|
215 |
-
|
216 |
// Remove groups from this ad
|
217 |
$delete = array_diff($group_array, $groups);
|
218 |
foreach($delete as &$value) {
|
219 |
-
$wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = %d AND `group` = %d AND `user` = 0 AND `schedule` = 0;", $id, $value));
|
220 |
}
|
221 |
unset($value);
|
222 |
-
|
223 |
// Verify ad
|
224 |
if($type == "empty") {
|
225 |
$action = 'new';
|
226 |
} else {
|
227 |
$action = 'update';
|
228 |
}
|
229 |
-
|
230 |
if($active == "active") {
|
231 |
// Verify all ads
|
232 |
adrotate_prepare_evaluate_ads(false);
|
233 |
}
|
234 |
-
|
235 |
adrotate_return('adrotate-ads', 200);
|
236 |
exit;
|
237 |
} else {
|
@@ -251,7 +251,7 @@ function adrotate_insert_input() {
|
|
251 |
function adrotate_insert_group() {
|
252 |
global $wpdb, $adrotate_config;
|
253 |
|
254 |
-
if(wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_save_group')) {
|
255 |
$action = $id = $name = $modus = '';
|
256 |
if(isset($_POST['adrotate_action'])) $action = $_POST['adrotate_action'];
|
257 |
if(isset($_POST['adrotate_id'])) $id = $_POST['adrotate_id'];
|
@@ -281,21 +281,21 @@ function adrotate_insert_group() {
|
|
281 |
$wrapper_before = $wrapper_after = '';
|
282 |
if(isset($_POST['adrotate_wrapper_before'])) $wrapper_before = trim($_POST['adrotate_wrapper_before'], "\t\n ");
|
283 |
if(isset($_POST['adrotate_wrapper_after'])) $wrapper_after = trim($_POST['adrotate_wrapper_after'], "\t\n ");
|
284 |
-
|
285 |
if(current_user_can('adrotate_group_manage')) {
|
286 |
if(strlen($name) < 1) $name = 'Group '.$id;
|
287 |
-
|
288 |
if($modus < 0 OR $modus > 2) $modus = 0;
|
289 |
if($adspeed < 0 OR $adspeed > 99999) $adspeed = 6000;
|
290 |
if($align < 0 OR $align > 3) $align = 0;
|
291 |
-
|
292 |
// Sort out block shape
|
293 |
if($rows < 1 OR $rows == '' OR !is_numeric($rows)) $rows = 2;
|
294 |
if($columns < 1 OR $columns == '' OR !is_numeric($columns)) $columns = 2;
|
295 |
if((is_numeric($adwidth) AND $adwidth < 1 OR $adwidth > 9999) OR $adwidth == '' OR (!is_numeric($adwidth) AND $adwidth != 'auto')) $adwidth = '125';
|
296 |
if((is_numeric($adheight) AND $adheight < 1 OR $adheight > 9999) OR $adheight == '' OR (!is_numeric($adheight) AND $adheight != 'auto')) $adheight = '125';
|
297 |
if($admargin < 0 OR $admargin > 99 OR $admargin == '' OR !is_numeric($admargin)) $admargin = 0;
|
298 |
-
|
299 |
// Categories
|
300 |
if(!is_array($categories)) $categories = array();
|
301 |
$category = '';
|
@@ -304,10 +304,10 @@ function adrotate_insert_group() {
|
|
304 |
}
|
305 |
$category = trim($category, ', ');
|
306 |
if(strlen($category) < 1) $category = '';
|
307 |
-
|
308 |
if($category_par > 0) $category_loc = 4;
|
309 |
if($category_loc != 4) $category_par = 0;
|
310 |
-
|
311 |
// Pages
|
312 |
if(!is_array($pages)) $pages = array();
|
313 |
$page = '';
|
@@ -316,7 +316,7 @@ function adrotate_insert_group() {
|
|
316 |
}
|
317 |
$page = trim($page, ',');
|
318 |
if(strlen($page) < 1) $page = '';
|
319 |
-
|
320 |
if($page_par > 0) $page_loc = 4;
|
321 |
if($page_loc != 4) $page_par = 0;
|
322 |
|
@@ -325,7 +325,7 @@ function adrotate_insert_group() {
|
|
325 |
foreach($linkmeta as $meta) {
|
326 |
$meta_array[] = $meta->ad;
|
327 |
}
|
328 |
-
|
329 |
if(empty($meta_array)) $meta_array = array();
|
330 |
if(empty($ads)) $ads = array();
|
331 |
|
@@ -335,14 +335,14 @@ function adrotate_insert_group() {
|
|
335 |
$wpdb->insert($wpdb->prefix.'adrotate_linkmeta', array('ad' => $value, 'group' => $id, 'user' => 0));
|
336 |
}
|
337 |
unset($value);
|
338 |
-
|
339 |
// Remove ads from this group
|
340 |
$delete = array_diff($meta_array,$ads);
|
341 |
foreach($delete as &$value) {
|
342 |
-
$wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = %d AND `group` = %d AND `user` = 0;", $value, $id));
|
343 |
}
|
344 |
unset($value);
|
345 |
-
|
346 |
// Update the group itself
|
347 |
$wpdb->update($wpdb->prefix.'adrotate_groups', array('name' => $name, 'modus' => $modus, 'fallback' => 0, 'cat' => $category, 'cat_loc' => $category_loc, 'cat_par' => $category_par, 'page' => $page, 'page_loc' => $page_loc, 'page_par' => $page_par, 'wrapper_before' => $wrapper_before, 'wrapper_after' => $wrapper_after, 'align' => $align, 'gridrows' => $rows, 'gridcolumns' => $columns, 'admargin' => $admargin, 'adwidth' => $adwidth, 'adheight' => $adheight, 'adspeed' => $adspeed), array('id' => $id));
|
348 |
|
@@ -366,17 +366,17 @@ function adrotate_insert_group() {
|
|
366 |
if($align < 3) {
|
367 |
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { margin:".$admargin."px; ".$group_align." }\n";
|
368 |
} else {
|
369 |
-
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { ".$group_align." }\n";
|
370 |
}
|
371 |
}
|
372 |
-
|
373 |
if($modus == 1) { // Dynamic group
|
374 |
if($adwidth != 'auto') {
|
375 |
$width = " width:100%; max-width:".$adwidth."px;";
|
376 |
} else {
|
377 |
$width = " width:auto;";
|
378 |
}
|
379 |
-
|
380 |
if($adheight != 'auto') {
|
381 |
$height = " height:100%; max-height:".$adheight."px;";
|
382 |
} else {
|
@@ -386,12 +386,12 @@ function adrotate_insert_group() {
|
|
386 |
if($align < 3) {
|
387 |
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { margin:".$admargin."px; ".$width.$height.$group_align." }\n";
|
388 |
} else {
|
389 |
-
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." {".$width.$height.$group_align." }\n";
|
390 |
}
|
391 |
|
392 |
unset($width_sum, $width, $height_sum, $height);
|
393 |
}
|
394 |
-
|
395 |
if($modus == 2) { // Block group
|
396 |
if($adwidth != 'auto') {
|
397 |
$width_sum = $columns * ($adwidth + ($admargin * 2));
|
@@ -399,7 +399,7 @@ function adrotate_insert_group() {
|
|
399 |
} else {
|
400 |
$grid_width = "width:auto;";
|
401 |
}
|
402 |
-
|
403 |
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { ".$grid_width.$group_align." }\n";
|
404 |
$output_css .= "\t.b".$adrotate_config['adblock_disguise']."-".$id." { margin:".$admargin."px; }\n";
|
405 |
unset($width_sum, $grid_width, $height_sum, $grid_height);
|
@@ -425,42 +425,43 @@ function adrotate_insert_group() {
|
|
425 |
/*-------------------------------------------------------------
|
426 |
Name: adrotate_insert_media
|
427 |
Purpose: Prepare input form on saving new or updated banners
|
428 |
-
Since: 0.1
|
429 |
-------------------------------------------------------------*/
|
430 |
function adrotate_insert_media() {
|
431 |
global $wpdb, $adrotate_config;
|
432 |
|
433 |
if(wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_save_media')) {
|
434 |
if(current_user_can('adrotate_ad_manage')) {
|
435 |
-
|
436 |
if($_FILES["adrotate_image"]["size"] > 0 AND $_FILES["adrotate_image"]["size"] <= 512000) {
|
437 |
$allowedExts = array("jpg", "jpeg", "gif", "png", "html", "js", "svg", "zip");
|
438 |
-
$
|
439 |
-
$
|
440 |
-
$
|
|
|
441 |
$location = esc_attr($_POST['adrotate_image_location']);
|
442 |
-
$
|
443 |
|
444 |
if(
|
445 |
(
|
446 |
//Images
|
447 |
$_FILES["adrotate_image"]["type"] == "image/gif"
|
448 |
-
OR $_FILES["adrotate_image"]["type"] == "image/jpeg"
|
449 |
OR $_FILES["adrotate_image"]["type"] == "image/pjpeg"
|
450 |
-
OR $_FILES["adrotate_image"]["type"] == "image/jpg"
|
451 |
OR $_FILES["adrotate_image"]["type"] == "image/png"
|
452 |
OR $_FILES["adrotate_image"]["type"] == "image/svg+xml"
|
453 |
-
|
454 |
// HTML5 Assets
|
455 |
OR $_FILES["adrotate_image"]["type"] == "text/html"
|
456 |
OR $_FILES["adrotate_image"]["type"] == "application/x-javascript"
|
457 |
OR $_FILES["adrotate_image"]["type"] == "application/javascript"
|
458 |
OR $_FILES["adrotate_image"]["type"] == "text/javascript"
|
459 |
-
|
460 |
// Zip files
|
461 |
OR $_FILES["adrotate_image"]["type"] == "application/zip"
|
462 |
)
|
463 |
-
AND in_array($
|
464 |
) {
|
465 |
if ($_FILES["adrotate_image"]["error"] > 0) {
|
466 |
if($_FILES["adrotate_image"]["error"] == 1 OR $_FILES["adrotate_image"]["error"] == 2) $errorcode = 511;
|
@@ -470,25 +471,28 @@ function adrotate_insert_media() {
|
|
470 |
else $errorcode = '';
|
471 |
adrotate_return('adrotate-media', $errorcode); // Other error
|
472 |
} else {
|
473 |
-
if(!move_uploaded_file($_FILES["adrotate_image"]["tmp_name"], $
|
474 |
adrotate_return('adrotate-media', 506); // Upload error
|
475 |
}
|
476 |
|
477 |
-
if($_FILES["adrotate_image"]["type"] == "application/zip" AND $
|
478 |
require_once(ABSPATH .'/wp-admin/includes/file.php');
|
479 |
|
480 |
-
$creds = request_filesystem_credentials(wp_nonce_url('admin.php?page=adrotate-media'), '', false, $
|
481 |
if(!WP_Filesystem($creds)) {
|
482 |
-
request_filesystem_credentials(wp_nonce_url('admin.php?page=adrotate-media'), '', true, $
|
483 |
}
|
484 |
|
485 |
-
$unzipfile = unzip_file($
|
486 |
if(is_wp_error($unzipfile)) {
|
487 |
adrotate_return('adrotate-media', 512); // Can not unzip file
|
488 |
}
|
489 |
|
|
|
|
|
|
|
490 |
// Delete the uploaded zip
|
491 |
-
adrotate_unlink($
|
492 |
}
|
493 |
|
494 |
adrotate_return('adrotate-media', 202); // Success
|
@@ -518,7 +522,7 @@ function adrotate_insert_folder() {
|
|
518 |
|
519 |
if(wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_save_media')) {
|
520 |
if(current_user_can('adrotate_ad_manage')) {
|
521 |
-
|
522 |
$folder = (isset($_POST['adrotate_folder'])) ? esc_attr(strip_tags(trim($_POST['adrotate_folder']))) : '';
|
523 |
|
524 |
if(strlen($folder) > 0 and strlen($folder) <= 100) {
|
@@ -551,15 +555,15 @@ function adrotate_request_action() {
|
|
551 |
|
552 |
$banner_ids = $group_ids = '';
|
553 |
|
554 |
-
if(wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_active') OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_disable')
|
555 |
-
OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_error') OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_queue')
|
556 |
OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_groups')) {
|
557 |
if(isset($_POST['bannercheck'])) $banner_ids = $_POST['bannercheck'];
|
558 |
if(isset($_POST['disabledbannercheck'])) $banner_ids = $_POST['disabledbannercheck'];
|
559 |
if(isset($_POST['errorbannercheck'])) $banner_ids = $_POST['errorbannercheck'];
|
560 |
if(isset($_POST['groupcheck'])) $group_ids = $_POST['groupcheck'];
|
561 |
if(isset($_POST['adrotate_id'])) $banner_ids = array($_POST['adrotate_id']);
|
562 |
-
|
563 |
// Determine which kind of action to use
|
564 |
if(isset($_POST['adrotate_action'])) {
|
565 |
// Default action call
|
@@ -572,11 +576,11 @@ function adrotate_request_action() {
|
|
572 |
$actions = $_POST['adrotate_error_action'];
|
573 |
}
|
574 |
if(preg_match("/-/", $actions)) {
|
575 |
-
list($action, $specific) = explode("-", $actions);
|
576 |
} else {
|
577 |
$action = $actions;
|
578 |
}
|
579 |
-
|
580 |
if($banner_ids != '') {
|
581 |
$return = 'adrotate-ads';
|
582 |
if($action == 'export') {
|
@@ -632,7 +636,7 @@ function adrotate_request_action() {
|
|
632 |
// Verify all ads
|
633 |
adrotate_prepare_evaluate_ads(false);
|
634 |
}
|
635 |
-
|
636 |
if($group_ids != '') {
|
637 |
$return = 'adrotate-groups';
|
638 |
foreach($group_ids as $group_id) {
|
@@ -654,7 +658,7 @@ function adrotate_request_action() {
|
|
654 |
}
|
655 |
}
|
656 |
}
|
657 |
-
|
658 |
adrotate_return($return, $result_id);
|
659 |
} else {
|
660 |
adrotate_nonce_error();
|
@@ -708,7 +712,7 @@ function adrotate_active($id, $what) {
|
|
708 |
$wpdb->update($wpdb->prefix.'adrotate', array('type' => 'disabled'), array('id' => $id));
|
709 |
}
|
710 |
if ($what == 'activate') {
|
711 |
-
// Determine status of ad
|
712 |
$adstate = adrotate_evaluate_ad($id);
|
713 |
$adtype = ($adstate == 'error' OR $adstate == 'expired') ? 'error' : 'active';
|
714 |
|
@@ -739,7 +743,7 @@ function adrotate_renew($id, $howlong = 2592000) {
|
|
739 |
global $wpdb;
|
740 |
|
741 |
if($id > 0) {
|
742 |
-
$schedule_id = $wpdb->get_var($wpdb->prepare("SELECT `schedule` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = %d AND `group` = 0 AND `user` = 0 ORDER BY `id` DESC LIMIT 1;", $id));
|
743 |
if($schedule_id > 0) {
|
744 |
$wpdb->query("UPDATE `{$wpdb->prefix}adrotate_schedule` SET `stoptime` = `stoptime` + $howlong WHERE `id` = $schedule_id;");
|
745 |
} else {
|
@@ -772,7 +776,7 @@ function adrotate_options_submit() {
|
|
772 |
|
773 |
$settings_tab = esc_attr($_POST['adrotate_settings_tab']);
|
774 |
|
775 |
-
if($settings_tab == 'general') {
|
776 |
$config = get_option('adrotate_config');
|
777 |
|
778 |
$config['mobile_dynamic_mode'] = (isset($_POST['adrotate_mobile_dynamic_mode'])) ? 'Y' : 'N';
|
@@ -803,7 +807,7 @@ function adrotate_options_submit() {
|
|
803 |
update_option('adrotate_crawlers', $new_crawlers);
|
804 |
}
|
805 |
|
806 |
-
if($settings_tab == 'notifications') {
|
807 |
$notifications = get_option('adrotate_notifications');
|
808 |
|
809 |
$notifications['notification_dash'] = (isset($_POST['adrotate_notification_dash'])) ? 'Y' : 'N';
|
@@ -824,7 +828,7 @@ function adrotate_options_submit() {
|
|
824 |
update_option('adrotate_notifications', $notifications);
|
825 |
}
|
826 |
|
827 |
-
if($settings_tab == 'stats') {
|
828 |
$config = get_option('adrotate_config');
|
829 |
|
830 |
$stats = trim($_POST['adrotate_stats']);
|
@@ -835,16 +839,16 @@ function adrotate_options_submit() {
|
|
835 |
|
836 |
if($config['enable_clean_trackerdata'] == "Y" AND !wp_next_scheduled('adrotate_delete_transients')) {
|
837 |
wp_schedule_event(current_time('timestamp'), 'twicedaily', 'adrotate_delete_transients');
|
838 |
-
}
|
839 |
if($config['enable_clean_trackerdata'] == "N" AND wp_next_scheduled('adrotate_delete_transients')) {
|
840 |
wp_clear_scheduled_hook('adrotate_delete_transients');
|
841 |
-
}
|
842 |
|
843 |
$impression_timer = trim($_POST['adrotate_impression_timer']);
|
844 |
$config['impression_timer'] = (is_numeric($impression_timer) AND $impression_timer >= 10 AND $impression_timer <= 3600) ? $impression_timer : 60;
|
845 |
$click_timer = trim($_POST['adrotate_click_timer']);
|
846 |
$config['click_timer'] = (is_numeric($click_timer) AND $click_timer >= 60 AND $click_timer <= 86400) ? $click_timer : 86400;
|
847 |
-
|
848 |
update_option('adrotate_config', $config);
|
849 |
}
|
850 |
|
@@ -863,7 +867,7 @@ function adrotate_options_submit() {
|
|
863 |
update_option('adrotate_config', $config);
|
864 |
}
|
865 |
|
866 |
-
if($settings_tab == 'misc') {
|
867 |
$config = get_option('adrotate_config');
|
868 |
|
869 |
$config['widgetalign'] = (isset($_POST['adrotate_widgetalign'])) ? 'Y' : 'N';
|
@@ -871,10 +875,10 @@ function adrotate_options_submit() {
|
|
871 |
$config['hide_schedules'] = (isset($_POST['adrotate_hide_schedules'])) ? 'Y' : 'N';
|
872 |
$config['w3caching'] = (isset($_POST['adrotate_w3caching'])) ? 'Y' : 'N';
|
873 |
$config['borlabscache'] = (isset($_POST['adrotate_borlabscache'])) ? 'Y' : 'N';
|
874 |
-
|
875 |
update_option('adrotate_config', $config);
|
876 |
}
|
877 |
-
|
878 |
// Return to dashboard
|
879 |
adrotate_return('adrotate-settings', 400, array('tab' => $settings_tab));
|
880 |
} else {
|
@@ -890,10 +894,10 @@ function adrotate_options_submit() {
|
|
890 |
-------------------------------------------------------------*/
|
891 |
function adrotate_prepare_roles($action) {
|
892 |
if($action == 'add') {
|
893 |
-
add_role('adrotate_advertiser', __('AdRotate Advertiser', 'adrotate'), array('read' => 1));
|
894 |
-
}
|
895 |
if($action == 'remove') {
|
896 |
remove_role('adrotate_advertiser');
|
897 |
-
}
|
898 |
}
|
899 |
?>
|
28 |
if(isset($_POST['adrotate_targeturl'])) $targeturl = strip_tags(trim($_POST['adrotate_targeturl'], "\t\n "));
|
29 |
|
30 |
$new_window = '';
|
31 |
+
if(isset($_POST['adrotate_newwindow'])) $new_window = strip_tags(trim($_POST['adrotate_newwindow'], "\t\n "));
|
32 |
|
33 |
$portability = '';
|
34 |
+
if(isset($_POST['adrotate_portability'])) $portability = strip_tags(trim($_POST['adrotate_portability'], "\t\n "));
|
35 |
|
36 |
if(current_user_can('adrotate_ad_manage')) {
|
37 |
if(strlen($portability) == 0) {
|
43 |
} else {
|
44 |
$adwidth = $adheight = '';
|
45 |
}
|
46 |
+
|
47 |
// Open in a new window?
|
48 |
if(isset($new_window) AND strlen($new_window) != 0) {
|
49 |
$new_window = ' target="_blank"';
|
50 |
} else {
|
51 |
$new_window = '';
|
52 |
}
|
53 |
+
|
54 |
// Determine image settings
|
55 |
$imagetype = "dropdown";
|
56 |
$image = WP_CONTENT_URL."/%folder%/".$fullsize_image;
|
57 |
$asset = "<img src=\"%asset%\"".$adwidth.$adheight." />";
|
58 |
+
|
59 |
// Generate code
|
60 |
$bannercode = "<a href=\"".$targeturl."\"".$new_window.">".$asset."</a>";
|
61 |
+
|
62 |
// Save the advert to the DB
|
63 |
$wpdb->update($wpdb->prefix.'adrotate', array('bannercode' => $bannercode, 'imagetype' => $imagetype, 'image' => $image), array('id' => $id));
|
64 |
} else {
|
82 |
/*-------------------------------------------------------------
|
83 |
Name: adrotate_insert_input
|
84 |
Purpose: Prepare input form on saving new or updated banners
|
85 |
+
Since: 0.1
|
86 |
-------------------------------------------------------------*/
|
87 |
function adrotate_insert_input() {
|
88 |
global $wpdb, $adrotate_config;
|
106 |
if(isset($_POST['adrotate_end_date'])) $end_date = strip_tags(trim($_POST['adrotate_end_date'], "\t\n "));
|
107 |
if(isset($_POST['adrotate_end_hour'])) $end_hour = strip_tags(trim($_POST['adrotate_end_hour'], "\t\n "));
|
108 |
if(isset($_POST['adrotate_end_minute'])) $end_minute = strip_tags(trim($_POST['adrotate_end_minute'], "\t\n "));
|
109 |
+
|
110 |
$maxclicks = $maxshown = '';
|
111 |
if(isset($_POST['adrotate_maxclicks'])) $maxclicks = strip_tags(trim($_POST['adrotate_maxclicks'], "\t\n "));
|
112 |
if(isset($_POST['adrotate_maxshown'])) $maxshown = strip_tags(trim($_POST['adrotate_maxshown'], "\t\n "));
|
117 |
if(isset($_POST['adrotate_image'])) $image_field = strip_tags(trim($_POST['adrotate_image'], "\t\n "));
|
118 |
if(isset($_POST['adrotate_image_dropdown'])) $image_dropdown = strip_tags(trim($_POST['adrotate_image_dropdown'], "\t\n "));
|
119 |
if(isset($_POST['adrotate_tracker'])) $tracker = strip_tags(trim($_POST['adrotate_tracker'], "\t\n "));
|
120 |
+
|
121 |
// Misc variables
|
122 |
$type = '';
|
123 |
$groups = array();
|
124 |
if(isset($_POST['groupselect'])) $groups = $_POST['groupselect'];
|
125 |
if(isset($_POST['adrotate_type'])) $type = strip_tags(trim($_POST['adrotate_type'], "\t\n "));
|
126 |
+
|
127 |
+
|
128 |
if(current_user_can('adrotate_ad_manage')) {
|
129 |
if(strlen($title) < 1) {
|
130 |
$title = 'Ad '.$id;
|
131 |
}
|
132 |
+
|
133 |
// Clean up bannercode
|
134 |
if(preg_match("/%ID%/", $bannercode)) $bannercode = str_replace('%ID%', '%id%', $bannercode);
|
135 |
if(preg_match("/%IMAGE%/", $bannercode)) $bannercode = str_replace('%IMAGE%', '%image%', $bannercode);
|
136 |
if(preg_match("/%TITLE%/", $bannercode)) $bannercode = str_replace('%TITLE%', '%title%', $bannercode);
|
137 |
if(preg_match("/%RANDOM%/", $bannercode)) $bannercode = str_replace('%RANDOM%', '%random%', $bannercode);
|
138 |
+
|
139 |
// Sort out start dates
|
140 |
if(strlen($start_date) > 0) {
|
141 |
list($start_day, $start_month, $start_year) = explode('-', $start_date); // dd/mm/yyyy
|
145 |
|
146 |
if(($start_year > 0 AND $start_month > 0 AND $start_day > 0) AND strlen($start_hour) == 0) $start_hour = '00';
|
147 |
if(($start_year > 0 AND $start_month > 0 AND $start_day > 0) AND strlen($start_minute) == 0) $start_minute = '00';
|
148 |
+
|
149 |
if($start_month > 0 AND $start_day > 0 AND $start_year > 0) {
|
150 |
$start_date = mktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year);
|
151 |
} else {
|
152 |
$start_date = 0;
|
153 |
}
|
154 |
+
|
155 |
// Sort out end dates
|
156 |
if(strlen($end_date) > 0) {
|
157 |
list($end_day, $end_month, $end_year) = explode('-', $end_date); // dd/mm/yyyy
|
161 |
|
162 |
if(($end_year > 0 AND $end_month > 0 AND $end_day > 0) AND strlen($end_hour) == 0) $end_hour = '00';
|
163 |
if(($end_year > 0 AND $end_month > 0 AND $end_day > 0) AND strlen($end_minute) == 0) $end_minute = '00';
|
164 |
+
|
165 |
if($end_month > 0 AND $end_day > 0 AND $end_year > 0) {
|
166 |
$end_date = mktime($end_hour, $end_minute, 0, $end_month, $end_day, $end_year);
|
167 |
} else {
|
168 |
$end_date = 0;
|
169 |
}
|
170 |
+
|
171 |
// Enddate is too early, reset to default
|
172 |
if($end_date <= $start_date) $end_date = $start_date + 7257600; // 84 days (12 weeks)
|
173 |
+
|
174 |
// Sort out click and impressions restrictions
|
175 |
if(strlen($maxclicks) < 1 OR !is_numeric($maxclicks)) $maxclicks = 0;
|
176 |
if(strlen($maxshown) < 1 OR !is_numeric($maxshown)) $maxshown = 0;
|
177 |
+
|
178 |
if(isset($tracker) AND strlen($tracker) != 0) $tracker = 'Y';
|
179 |
else $tracker = 'N';
|
180 |
+
|
181 |
// Determine image settings ($image_field has priority!)
|
182 |
if(strlen($image_field) > 1) {
|
183 |
$imagetype = "field";
|
189 |
$imagetype = "";
|
190 |
$image = "";
|
191 |
}
|
192 |
+
|
193 |
// Save schedule for new ads or update the existing one
|
194 |
if($type != 'empty') {
|
195 |
+
$wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}adrotate_schedule` WHERE `id` IN (SELECT `schedule` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `schedule` != %d AND `schedule` > 0 AND `ad` = %d AND `group` = 0 AND `user` = 0);", $schedule_id, $id));
|
196 |
}
|
197 |
$wpdb->update($wpdb->prefix.'adrotate_schedule', array('starttime' => $start_date, 'stoptime' => $end_date, 'maxclicks' => $maxclicks, 'maximpressions' => $maxshown), array('id' => $schedule_id));
|
198 |
|
205 |
foreach($groupmeta as $meta) {
|
206 |
$group_array[] = $meta->group;
|
207 |
}
|
208 |
+
|
209 |
// Add new groups to this ad
|
210 |
$insert = array_diff($groups, $group_array);
|
211 |
foreach($insert as &$value) {
|
212 |
$wpdb->insert($wpdb->prefix.'adrotate_linkmeta', array('ad' => $id, 'group' => $value, 'user' => 0, 'schedule' => 0));
|
213 |
}
|
214 |
unset($value);
|
215 |
+
|
216 |
// Remove groups from this ad
|
217 |
$delete = array_diff($group_array, $groups);
|
218 |
foreach($delete as &$value) {
|
219 |
+
$wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = %d AND `group` = %d AND `user` = 0 AND `schedule` = 0;", $id, $value));
|
220 |
}
|
221 |
unset($value);
|
222 |
+
|
223 |
// Verify ad
|
224 |
if($type == "empty") {
|
225 |
$action = 'new';
|
226 |
} else {
|
227 |
$action = 'update';
|
228 |
}
|
229 |
+
|
230 |
if($active == "active") {
|
231 |
// Verify all ads
|
232 |
adrotate_prepare_evaluate_ads(false);
|
233 |
}
|
234 |
+
|
235 |
adrotate_return('adrotate-ads', 200);
|
236 |
exit;
|
237 |
} else {
|
251 |
function adrotate_insert_group() {
|
252 |
global $wpdb, $adrotate_config;
|
253 |
|
254 |
+
if(wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_save_group')) {
|
255 |
$action = $id = $name = $modus = '';
|
256 |
if(isset($_POST['adrotate_action'])) $action = $_POST['adrotate_action'];
|
257 |
if(isset($_POST['adrotate_id'])) $id = $_POST['adrotate_id'];
|
281 |
$wrapper_before = $wrapper_after = '';
|
282 |
if(isset($_POST['adrotate_wrapper_before'])) $wrapper_before = trim($_POST['adrotate_wrapper_before'], "\t\n ");
|
283 |
if(isset($_POST['adrotate_wrapper_after'])) $wrapper_after = trim($_POST['adrotate_wrapper_after'], "\t\n ");
|
284 |
+
|
285 |
if(current_user_can('adrotate_group_manage')) {
|
286 |
if(strlen($name) < 1) $name = 'Group '.$id;
|
287 |
+
|
288 |
if($modus < 0 OR $modus > 2) $modus = 0;
|
289 |
if($adspeed < 0 OR $adspeed > 99999) $adspeed = 6000;
|
290 |
if($align < 0 OR $align > 3) $align = 0;
|
291 |
+
|
292 |
// Sort out block shape
|
293 |
if($rows < 1 OR $rows == '' OR !is_numeric($rows)) $rows = 2;
|
294 |
if($columns < 1 OR $columns == '' OR !is_numeric($columns)) $columns = 2;
|
295 |
if((is_numeric($adwidth) AND $adwidth < 1 OR $adwidth > 9999) OR $adwidth == '' OR (!is_numeric($adwidth) AND $adwidth != 'auto')) $adwidth = '125';
|
296 |
if((is_numeric($adheight) AND $adheight < 1 OR $adheight > 9999) OR $adheight == '' OR (!is_numeric($adheight) AND $adheight != 'auto')) $adheight = '125';
|
297 |
if($admargin < 0 OR $admargin > 99 OR $admargin == '' OR !is_numeric($admargin)) $admargin = 0;
|
298 |
+
|
299 |
// Categories
|
300 |
if(!is_array($categories)) $categories = array();
|
301 |
$category = '';
|
304 |
}
|
305 |
$category = trim($category, ', ');
|
306 |
if(strlen($category) < 1) $category = '';
|
307 |
+
|
308 |
if($category_par > 0) $category_loc = 4;
|
309 |
if($category_loc != 4) $category_par = 0;
|
310 |
+
|
311 |
// Pages
|
312 |
if(!is_array($pages)) $pages = array();
|
313 |
$page = '';
|
316 |
}
|
317 |
$page = trim($page, ',');
|
318 |
if(strlen($page) < 1) $page = '';
|
319 |
+
|
320 |
if($page_par > 0) $page_loc = 4;
|
321 |
if($page_loc != 4) $page_par = 0;
|
322 |
|
325 |
foreach($linkmeta as $meta) {
|
326 |
$meta_array[] = $meta->ad;
|
327 |
}
|
328 |
+
|
329 |
if(empty($meta_array)) $meta_array = array();
|
330 |
if(empty($ads)) $ads = array();
|
331 |
|
335 |
$wpdb->insert($wpdb->prefix.'adrotate_linkmeta', array('ad' => $value, 'group' => $id, 'user' => 0));
|
336 |
}
|
337 |
unset($value);
|
338 |
+
|
339 |
// Remove ads from this group
|
340 |
$delete = array_diff($meta_array,$ads);
|
341 |
foreach($delete as &$value) {
|
342 |
+
$wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = %d AND `group` = %d AND `user` = 0;", $value, $id));
|
343 |
}
|
344 |
unset($value);
|
345 |
+
|
346 |
// Update the group itself
|
347 |
$wpdb->update($wpdb->prefix.'adrotate_groups', array('name' => $name, 'modus' => $modus, 'fallback' => 0, 'cat' => $category, 'cat_loc' => $category_loc, 'cat_par' => $category_par, 'page' => $page, 'page_loc' => $page_loc, 'page_par' => $page_par, 'wrapper_before' => $wrapper_before, 'wrapper_after' => $wrapper_after, 'align' => $align, 'gridrows' => $rows, 'gridcolumns' => $columns, 'admargin' => $admargin, 'adwidth' => $adwidth, 'adheight' => $adheight, 'adspeed' => $adspeed), array('id' => $id));
|
348 |
|
366 |
if($align < 3) {
|
367 |
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { margin:".$admargin."px; ".$group_align." }\n";
|
368 |
} else {
|
369 |
+
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { ".$group_align." }\n";
|
370 |
}
|
371 |
}
|
372 |
+
|
373 |
if($modus == 1) { // Dynamic group
|
374 |
if($adwidth != 'auto') {
|
375 |
$width = " width:100%; max-width:".$adwidth."px;";
|
376 |
} else {
|
377 |
$width = " width:auto;";
|
378 |
}
|
379 |
+
|
380 |
if($adheight != 'auto') {
|
381 |
$height = " height:100%; max-height:".$adheight."px;";
|
382 |
} else {
|
386 |
if($align < 3) {
|
387 |
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { margin:".$admargin."px; ".$width.$height.$group_align." }\n";
|
388 |
} else {
|
389 |
+
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." {".$width.$height.$group_align." }\n";
|
390 |
}
|
391 |
|
392 |
unset($width_sum, $width, $height_sum, $height);
|
393 |
}
|
394 |
+
|
395 |
if($modus == 2) { // Block group
|
396 |
if($adwidth != 'auto') {
|
397 |
$width_sum = $columns * ($adwidth + ($admargin * 2));
|
399 |
} else {
|
400 |
$grid_width = "width:auto;";
|
401 |
}
|
402 |
+
|
403 |
$output_css .= "\t.g".$adrotate_config['adblock_disguise']."-".$id." { ".$grid_width.$group_align." }\n";
|
404 |
$output_css .= "\t.b".$adrotate_config['adblock_disguise']."-".$id." { margin:".$admargin."px; }\n";
|
405 |
unset($width_sum, $grid_width, $height_sum, $grid_height);
|
425 |
/*-------------------------------------------------------------
|
426 |
Name: adrotate_insert_media
|
427 |
Purpose: Prepare input form on saving new or updated banners
|
428 |
+
Since: 0.1
|
429 |
-------------------------------------------------------------*/
|
430 |
function adrotate_insert_media() {
|
431 |
global $wpdb, $adrotate_config;
|
432 |
|
433 |
if(wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_save_media')) {
|
434 |
if(current_user_can('adrotate_ad_manage')) {
|
435 |
+
|
436 |
if($_FILES["adrotate_image"]["size"] > 0 AND $_FILES["adrotate_image"]["size"] <= 512000) {
|
437 |
$allowedExts = array("jpg", "jpeg", "gif", "png", "html", "js", "svg", "zip");
|
438 |
+
$file = adrotate_sanitize_file_name($_FILES["adrotate_image"]["name"]);
|
439 |
+
$file = explode(".", $file);
|
440 |
+
$file_extension = array_pop($file);
|
441 |
+
$file_name = implode('.', $file);
|
442 |
$location = esc_attr($_POST['adrotate_image_location']);
|
443 |
+
$file_path = WP_CONTENT_DIR."/".$location."/";
|
444 |
|
445 |
if(
|
446 |
(
|
447 |
//Images
|
448 |
$_FILES["adrotate_image"]["type"] == "image/gif"
|
449 |
+
OR $_FILES["adrotate_image"]["type"] == "image/jpeg"
|
450 |
OR $_FILES["adrotate_image"]["type"] == "image/pjpeg"
|
451 |
+
OR $_FILES["adrotate_image"]["type"] == "image/jpg"
|
452 |
OR $_FILES["adrotate_image"]["type"] == "image/png"
|
453 |
OR $_FILES["adrotate_image"]["type"] == "image/svg+xml"
|
454 |
+
|
455 |
// HTML5 Assets
|
456 |
OR $_FILES["adrotate_image"]["type"] == "text/html"
|
457 |
OR $_FILES["adrotate_image"]["type"] == "application/x-javascript"
|
458 |
OR $_FILES["adrotate_image"]["type"] == "application/javascript"
|
459 |
OR $_FILES["adrotate_image"]["type"] == "text/javascript"
|
460 |
+
|
461 |
// Zip files
|
462 |
OR $_FILES["adrotate_image"]["type"] == "application/zip"
|
463 |
)
|
464 |
+
AND in_array($file_extension, $allowedExts)
|
465 |
) {
|
466 |
if ($_FILES["adrotate_image"]["error"] > 0) {
|
467 |
if($_FILES["adrotate_image"]["error"] == 1 OR $_FILES["adrotate_image"]["error"] == 2) $errorcode = 511;
|
471 |
else $errorcode = '';
|
472 |
adrotate_return('adrotate-media', $errorcode); // Other error
|
473 |
} else {
|
474 |
+
if(!move_uploaded_file($_FILES["adrotate_image"]["tmp_name"], $file_path.$file_name.'.'.$file_extension)) {
|
475 |
adrotate_return('adrotate-media', 506); // Upload error
|
476 |
}
|
477 |
|
478 |
+
if($_FILES["adrotate_image"]["type"] == "application/zip" AND $file_extension == "zip") {
|
479 |
require_once(ABSPATH .'/wp-admin/includes/file.php');
|
480 |
|
481 |
+
$creds = request_filesystem_credentials(wp_nonce_url('admin.php?page=adrotate-media'), '', false, $file_path, null);
|
482 |
if(!WP_Filesystem($creds)) {
|
483 |
+
request_filesystem_credentials(wp_nonce_url('admin.php?page=adrotate-media'), '', true, $file_path, null);
|
484 |
}
|
485 |
|
486 |
+
$unzipfile = unzip_file($file_path.$file_name.'.'.$file_extension, $file_path.'/'.$file_name);
|
487 |
if(is_wp_error($unzipfile)) {
|
488 |
adrotate_return('adrotate-media', 512); // Can not unzip file
|
489 |
}
|
490 |
|
491 |
+
// Delete unwanted files
|
492 |
+
adrotate_clean_folder_contents($file_path.$file_name);
|
493 |
+
|
494 |
// Delete the uploaded zip
|
495 |
+
adrotate_unlink($file_name.'.'.$file_extension);
|
496 |
}
|
497 |
|
498 |
adrotate_return('adrotate-media', 202); // Success
|
522 |
|
523 |
if(wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_save_media')) {
|
524 |
if(current_user_can('adrotate_ad_manage')) {
|
525 |
+
|
526 |
$folder = (isset($_POST['adrotate_folder'])) ? esc_attr(strip_tags(trim($_POST['adrotate_folder']))) : '';
|
527 |
|
528 |
if(strlen($folder) > 0 and strlen($folder) <= 100) {
|
555 |
|
556 |
$banner_ids = $group_ids = '';
|
557 |
|
558 |
+
if(wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_active') OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_disable')
|
559 |
+
OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_error') OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_ads_queue')
|
560 |
OR wp_verify_nonce($_POST['adrotate_nonce'],'adrotate_bulk_groups')) {
|
561 |
if(isset($_POST['bannercheck'])) $banner_ids = $_POST['bannercheck'];
|
562 |
if(isset($_POST['disabledbannercheck'])) $banner_ids = $_POST['disabledbannercheck'];
|
563 |
if(isset($_POST['errorbannercheck'])) $banner_ids = $_POST['errorbannercheck'];
|
564 |
if(isset($_POST['groupcheck'])) $group_ids = $_POST['groupcheck'];
|
565 |
if(isset($_POST['adrotate_id'])) $banner_ids = array($_POST['adrotate_id']);
|
566 |
+
|
567 |
// Determine which kind of action to use
|
568 |
if(isset($_POST['adrotate_action'])) {
|
569 |
// Default action call
|
576 |
$actions = $_POST['adrotate_error_action'];
|
577 |
}
|
578 |
if(preg_match("/-/", $actions)) {
|
579 |
+
list($action, $specific) = explode("-", $actions);
|
580 |
} else {
|
581 |
$action = $actions;
|
582 |
}
|
583 |
+
|
584 |
if($banner_ids != '') {
|
585 |
$return = 'adrotate-ads';
|
586 |
if($action == 'export') {
|
636 |
// Verify all ads
|
637 |
adrotate_prepare_evaluate_ads(false);
|
638 |
}
|
639 |
+
|
640 |
if($group_ids != '') {
|
641 |
$return = 'adrotate-groups';
|
642 |
foreach($group_ids as $group_id) {
|
658 |
}
|
659 |
}
|
660 |
}
|
661 |
+
|
662 |
adrotate_return($return, $result_id);
|
663 |
} else {
|
664 |
adrotate_nonce_error();
|
712 |
$wpdb->update($wpdb->prefix.'adrotate', array('type' => 'disabled'), array('id' => $id));
|
713 |
}
|
714 |
if ($what == 'activate') {
|
715 |
+
// Determine status of ad
|
716 |
$adstate = adrotate_evaluate_ad($id);
|
717 |
$adtype = ($adstate == 'error' OR $adstate == 'expired') ? 'error' : 'active';
|
718 |
|
743 |
global $wpdb;
|
744 |
|
745 |
if($id > 0) {
|
746 |
+
$schedule_id = $wpdb->get_var($wpdb->prepare("SELECT `schedule` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = %d AND `group` = 0 AND `user` = 0 ORDER BY `id` DESC LIMIT 1;", $id));
|
747 |
if($schedule_id > 0) {
|
748 |
$wpdb->query("UPDATE `{$wpdb->prefix}adrotate_schedule` SET `stoptime` = `stoptime` + $howlong WHERE `id` = $schedule_id;");
|
749 |
} else {
|
776 |
|
777 |
$settings_tab = esc_attr($_POST['adrotate_settings_tab']);
|
778 |
|
779 |
+
if($settings_tab == 'general') {
|
780 |
$config = get_option('adrotate_config');
|
781 |
|
782 |
$config['mobile_dynamic_mode'] = (isset($_POST['adrotate_mobile_dynamic_mode'])) ? 'Y' : 'N';
|
807 |
update_option('adrotate_crawlers', $new_crawlers);
|
808 |
}
|
809 |
|
810 |
+
if($settings_tab == 'notifications') {
|
811 |
$notifications = get_option('adrotate_notifications');
|
812 |
|
813 |
$notifications['notification_dash'] = (isset($_POST['adrotate_notification_dash'])) ? 'Y' : 'N';
|
828 |
update_option('adrotate_notifications', $notifications);
|
829 |
}
|
830 |
|
831 |
+
if($settings_tab == 'stats') {
|
832 |
$config = get_option('adrotate_config');
|
833 |
|
834 |
$stats = trim($_POST['adrotate_stats']);
|
839 |
|
840 |
if($config['enable_clean_trackerdata'] == "Y" AND !wp_next_scheduled('adrotate_delete_transients')) {
|
841 |
wp_schedule_event(current_time('timestamp'), 'twicedaily', 'adrotate_delete_transients');
|
842 |
+
}
|
843 |
if($config['enable_clean_trackerdata'] == "N" AND wp_next_scheduled('adrotate_delete_transients')) {
|
844 |
wp_clear_scheduled_hook('adrotate_delete_transients');
|
845 |
+
}
|
846 |
|
847 |
$impression_timer = trim($_POST['adrotate_impression_timer']);
|
848 |
$config['impression_timer'] = (is_numeric($impression_timer) AND $impression_timer >= 10 AND $impression_timer <= 3600) ? $impression_timer : 60;
|
849 |
$click_timer = trim($_POST['adrotate_click_timer']);
|
850 |
$config['click_timer'] = (is_numeric($click_timer) AND $click_timer >= 60 AND $click_timer <= 86400) ? $click_timer : 86400;
|
851 |
+
|
852 |
update_option('adrotate_config', $config);
|
853 |
}
|
854 |
|
867 |
update_option('adrotate_config', $config);
|
868 |
}
|
869 |
|
870 |
+
if($settings_tab == 'misc') {
|
871 |
$config = get_option('adrotate_config');
|
872 |
|
873 |
$config['widgetalign'] = (isset($_POST['adrotate_widgetalign'])) ? 'Y' : 'N';
|
875 |
$config['hide_schedules'] = (isset($_POST['adrotate_hide_schedules'])) ? 'Y' : 'N';
|
876 |
$config['w3caching'] = (isset($_POST['adrotate_w3caching'])) ? 'Y' : 'N';
|
877 |
$config['borlabscache'] = (isset($_POST['adrotate_borlabscache'])) ? 'Y' : 'N';
|
878 |
+
|
879 |
update_option('adrotate_config', $config);
|
880 |
}
|
881 |
+
|
882 |
// Return to dashboard
|
883 |
adrotate_return('adrotate-settings', 400, array('tab' => $settings_tab));
|
884 |
} else {
|
894 |
-------------------------------------------------------------*/
|
895 |
function adrotate_prepare_roles($action) {
|
896 |
if($action == 'add') {
|
897 |
+
add_role('adrotate_advertiser', __('AdRotate Advertiser', 'adrotate'), array('read' => 1));
|
898 |
+
}
|
899 |
if($action == 'remove') {
|
900 |
remove_role('adrotate_advertiser');
|
901 |
+
}
|
902 |
}
|
903 |
?>
|
adrotate.php
CHANGED
@@ -6,7 +6,7 @@ Author: Arnan de Gans
|
|
6 |
Author URI: https://www.arnan.me/?pk_campaign=adrotatefree&pk_keyword=plugin_info
|
7 |
Description: Monetize your website with adverts while keeping things simple. Start making money today!
|
8 |
Text Domain: adrotate
|
9 |
-
Version: 5.8.
|
10 |
License: GPLv3
|
11 |
*/
|
12 |
|
@@ -21,7 +21,7 @@ License: GPLv3
|
|
21 |
------------------------------------------------------------------------------------ */
|
22 |
|
23 |
/*--- AdRotate values ---------------------------------------*/
|
24 |
-
define("ADROTATE_DISPLAY", '5.8.
|
25 |
define("ADROTATE_VERSION", 399);
|
26 |
define("ADROTATE_DB_VERSION", 66);
|
27 |
$plugin_folder = plugin_dir_path(__FILE__);
|
6 |
Author URI: https://www.arnan.me/?pk_campaign=adrotatefree&pk_keyword=plugin_info
|
7 |
Description: Monetize your website with adverts while keeping things simple. Start making money today!
|
8 |
Text Domain: adrotate
|
9 |
+
Version: 5.8.11
|
10 |
License: GPLv3
|
11 |
*/
|
12 |
|
21 |
------------------------------------------------------------------------------------ */
|
22 |
|
23 |
/*--- AdRotate values ---------------------------------------*/
|
24 |
+
define("ADROTATE_DISPLAY", '5.8.11');
|
25 |
define("ADROTATE_VERSION", 399);
|
26 |
define("ADROTATE_DB_VERSION", 66);
|
27 |
$plugin_folder = plugin_dir_path(__FILE__);
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: adverts, ads, banners, advert manager, ad manager, banner manager, monetis
|
|
5 |
Requires at least: 5.0
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.5.1
|
8 |
-
Stable tag: 5.8.
|
9 |
License: GPLv3
|
10 |
|
11 |
AdRotate is the only advert manager you'll ever need. Manage all your Google AdSense, Media.net, Amazon banners and more. Manage your ads.txt, widgets and many more powerful features to run successful campaigns.
|
5 |
Requires at least: 5.0
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.5.1
|
8 |
+
Stable tag: 5.8.11
|
9 |
License: GPLv3
|
10 |
|
11 |
AdRotate is the only advert manager you'll ever need. Manage all your Google AdSense, Media.net, Amazon banners and more. Manage your ads.txt, widgets and many more powerful features to run successful campaigns.
|