PluginProbe
AdRotate Banner Manager / 5.17.7
AdRotate Banner Manager v5.17.7
5.19.2 5.19.1 5.19 5.18 5.17.8 5.17.7 trunk 4.0 4.1 4.10 4.11 4.11.1 4.11.2 4.12 4.12.1 4.12.2 4.12.3 4.13 4.13.1 4.13.2 4.13.3 4.13.4 4.13.5 4.14 4.15 All 133 releases
adrotate / adrotate.php

adrotate.php in AdRotate Banner Manager 5.17.7, at adrotate.php

463 lines 17.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: AdRotate Banner Manager
4 Plugin URI: https://ajdg.solutions/product/adrotate-banner-manager/
5 Author: Arnan de Gans
6 Author URI: https://www.arnan.me/
7 Description: Everything you need to manage all your ads, banners and affiliate links while keeping things simple.
8 Version: 5.17.7
9 License: GPLv3
10
11 Text Domain: adrotate
12 Domain Path: /languages
13
14 Requires at least: 4.9
15 Requires PHP: 8.0
16 GooseUp: compatible
17 */
18
19 /* ------------------------------------------------------------------------------------
20 * COPYRIGHT AND TRADEMARK NOTICE
21 * Copyright 2008-2026 Arnan de Gans. All Rights Reserved.
22 * ADROTATE is a registered trademark of Arnan de Gans.
23
24 * COPYRIGHT NOTICES AND ALL THE COMMENTS SHOULD REMAIN INTACT.
25 * By using this code you agree to indemnify Arnan de Gans from any
26 * liability that might arise from its use.
27 ------------------------------------------------------------------------------------ */
28
29 /*--- AdRotate values ---------------------------------------*/
30 define('ADROTATE_VERSION', 408);
31 define('ADROTATE_DB_VERSION', 76);
32 $adrotate_path = plugin_dir_path(__FILE__);
33 /*-----------------------------------------------------------*/
34
35 /*--- Load Files --------------------------------------------*/
36 include_once($adrotate_path.'/adrotate-functions.php');
37 include_once($adrotate_path.'/adrotate-statistics.php');
38 include_once($adrotate_path.'/adrotate-output.php');
39 include_once($adrotate_path.'/adrotate-widget.php');
40 if(function_exists('register_block_type')) include_once($adrotate_path.'/adrotate-block.php');
41 /*-----------------------------------------------------------*/
42
43 /*--- Setup -------------------------------------------------*/
44 register_activation_hook(__FILE__, 'adrotate_activate');
45 register_deactivation_hook(__FILE__, 'adrotate_deactivate');
46 register_uninstall_hook(__FILE__, 'adrotate_uninstall');
47 /*-----------------------------------------------------------*/
48
49 /*--- Check and Load config ---------------------------------*/
50 load_plugin_textdomain('adrotate', false, 'adrotate/languages');
51 $adrotate_config = get_option("adrotate_config");
52 $adrotate_crawlers = get_option("adrotate_crawlers");
53 $adrotate_version = get_option("adrotate_version");
54 $adrotate_db_version = get_option("adrotate_db_version");
55 /*-----------------------------------------------------------*/
56
57 /*--- Core --------------------------------------------------*/
58 add_action('adrotate_empty_trackerdata', 'adrotate_empty_trackerdata');
59 add_action('widgets_init', 'adrotate_widget');
60 add_filter('adrotate_apply_photon','adrotate_apply_jetpack_photon');
61 /*-----------------------------------------------------------*/
62
63 /*--- Front end ---------------------------------------------*/
64 if(!is_admin()) {
65 add_action('wp_head', 'adrotate_header');
66 add_action('wp_enqueue_scripts', 'adrotate_scripts');
67 add_shortcode('adrotate', 'adrotate_shortcode');
68 add_filter('the_content', 'adrotate_inject_posts', 12);
69 }
70
71 if(is_array($adrotate_config) AND $adrotate_config['stats'] == 1){
72 add_action('wp_ajax_adrotate_impression', 'adrotate_impression_callback');
73 add_action('wp_ajax_nopriv_adrotate_impression', 'adrotate_impression_callback');
74 add_action('wp_ajax_adrotate_click', 'adrotate_click_callback');
75 add_action('wp_ajax_nopriv_adrotate_click', 'adrotate_click_callback');
76 }
77 /*-----------------------------------------------------------*/
78
79 /*--- Back End ----------------------------------------------*/
80 if(is_admin()) {
81 include_once($adrotate_path.'/adrotate-setup.php');
82 include_once($adrotate_path.'/adrotate-admin-functions.php');
83 include_once($adrotate_path.'/adrotate-admin-manage.php');
84 include_once($adrotate_path.'/adrotate-admin-statistics.php');
85 include_once($adrotate_path.'/adrotate-admin-portability.php');
86
87 /*--- Dashboard hooks ---------------------------------------*/
88 add_action('admin_menu', 'adrotate_dashboard');
89 add_action('admin_enqueue_scripts', 'adrotate_dashboard_scripts');
90 add_action('admin_notices','adrotate_notifications_dashboard');
91 add_filter('plugin_row_meta', 'adrotate_meta_links', 10, 2);
92 add_filter('plugin_action_links_' . plugin_basename( __FILE__ ), 'adrotate_action_links');
93
94 /*--- Internal redirects ------------------------------------*/
95 if(isset($_POST['adrotate_generate_submit'])) add_action('init', 'adrotate_generate_input');
96 if(isset($_POST['adrotate_advert_submit'])) add_action('init', 'adrotate_insert_advert');
97 if(isset($_POST['adrotate_group_submit'])) add_action('init', 'adrotate_insert_group');
98 if(isset($_POST['adrotate_upload_media'])) add_action('init', 'adrotate_insert_media');
99 if(isset($_POST['adrotate_create_folder'])) add_action('init', 'adrotate_insert_folder');
100 if(isset($_POST['adrotate_action_submit'])) add_action('init', 'adrotate_request_action');
101 if(isset($_POST['adrotate_save_options'])) add_action('init', 'adrotate_save_options');
102 }
103
104 /*-------------------------------------------------------------
105 Name: adrotate_dashboard
106 Purpose: Add pages to admin menus
107 -------------------------------------------------------------*/
108 function adrotate_dashboard() {
109 add_menu_page('AdRotate', 'AdRotate', 'adrotate_ad_manage', 'adrotate', 'adrotate_manage', plugins_url('/images/icon-menu.png', __FILE__), '25.8');
110 add_submenu_page('adrotate', 'AdRotate · '.__("Manage Adverts", 'adrotate'), __("Manage Adverts", 'adrotate'), 'adrotate_ad_manage', 'adrotate', 'adrotate_manage');
111 add_submenu_page('adrotate', 'AdRotate · '.__("Manage Groups", 'adrotate'), __("Manage Groups", 'adrotate'), 'adrotate_group_manage', 'adrotate-groups', 'adrotate_manage_group');
112 add_submenu_page('adrotate', 'AdRotate · '.__("Manage Schedules", 'adrotate'), __("Manage Schedules", 'adrotate'), 'adrotate_ad_manage', 'adrotate-schedules', 'adrotate_manage_schedules');
113 add_submenu_page('adrotate', 'AdRotate · '.__("Manage Media", 'adrotate'), __("Manage Media", 'adrotate'), 'adrotate_ad_manage', 'adrotate-media', 'adrotate_manage_media');
114 add_submenu_page('adrotate', 'AdRotate · '.__("Statistics", 'adrotate'), __("Statistics", 'adrotate'), 'adrotate_ad_manage', 'adrotate-statistics', 'adrotate_statistics');
115 add_submenu_page('adrotate', 'AdRotate · '.__("Get AdRotate Pro", 'adrotate'), __("Get AdRotate Pro", 'adrotate'), 'adrotate_ad_manage', 'adrotate-pro', 'adrotate_pro');
116 add_submenu_page('adrotate', 'AdRotate · '.__("Support", 'adrotate'), __("Support", 'adrotate'), 'manage_options', 'adrotate-support', 'adrotate_support');
117 add_submenu_page('adrotate', 'AdRotate · '.__("Settings", 'adrotate'), __("Settings", 'adrotate'), 'manage_options', 'adrotate-settings', 'adrotate_options');
118 }
119
120 /*-------------------------------------------------------------
121 Name: adrotate_pro
122 Purpose: AdRotate Pro Sales
123 -------------------------------------------------------------*/
124 function adrotate_pro() {
125 ?>
126 <div class="wrap">
127 <h1><?php _e("Get AdRotate Professional", 'adrotate'); ?></h1>
128
129 <?php include('dashboard/adrotatepro.php'); ?>
130
131 <br class="clear" />
132 </div>
133 <?php
134 }
135
136 /*-------------------------------------------------------------
137 Name: adrotate_manage
138 Purpose: Admin management page
139 -------------------------------------------------------------*/
140 function adrotate_manage() {
141 global $wpdb, $userdata, $adrotate_config;
142
143 $view = (isset($_GET['view'])) ? sanitize_key($_GET['view']) : '';
144 $status = (isset($_GET['status'])) ? sanitize_key($_GET['status']) : '';
145 $ad_edit_id =(isset($_GET['ad'])) ? sanitize_key($_GET['ad']) : '';
146 $file = (isset($_GET['file'])) ? sanitize_file_name($_GET['file']) : '';
147
148 if(!is_numeric($status)) $status = 0;
149 if(!is_numeric($ad_edit_id)) $ad_edit_id = 0;
150
151 $now = current_time('timestamp');
152 $today = adrotate_date_start('day');
153 $in2days = $now + 172800;
154 $in7days = $now + 604800;
155 $in84days = $now + 7257600;
156
157 if(isset($_GET['month']) AND isset($_GET['year'])) {
158 $month = sanitize_key($_GET['month']);
159 $year = sanitize_key($_GET['year']);
160 } else {
161 $month = date('m');
162 $year = date('Y');
163 }
164 $monthstart = mktime(0, 0, 0, $month, 1, $year);
165 $monthend = mktime(0, 0, 0, $month+1, 0, $year);
166 ?>
167 <div class="wrap">
168 <h1><?php _e("Manage Adverts", 'adrotate'); ?></h1>
169
170 <?php
171 if($status > 0) adrotate_status($status, array('file' => $file));
172 ?>
173
174 <div class="tablenav">
175 <div class="alignleft actions">
176 <a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate');?>"><?php _e("Manage", 'adrotate'); ?></a>
177 &nbsp;|&nbsp;<a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate&view=generator');?>"><?php _e("Advert Generator", 'adrotate'); ?></a>
178 &nbsp;|&nbsp;<a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate&view=addnew');?>"><?php _e("New Advert", 'adrotate'); ?></a>
179 &nbsp;|&nbsp;<a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-pro');?>"><?php _e("Get AdRotate Pro", 'adrotate'); ?></a>
180 </div>
181 </div>
182
183 <?php
184
185 if(empty($view) OR $view == 'manage') {
186 include('dashboard/publisher/manage-adverts.php');
187 } else if($view == 'addnew' OR $view == 'edit') {
188 include('dashboard/publisher/manage-adverts-edit.php');
189 } else if($view == 'generator') {
190 include('dashboard/publisher/manage-adverts-generator.php');
191 }
192 ?>
193 </div>
194 <?php
195 }
196
197 /*-------------------------------------------------------------
198 Name: adrotate_manage_group
199 Purpose: Manage groups
200 -------------------------------------------------------------*/
201 function adrotate_manage_group() {
202 global $wpdb, $adrotate_config;
203
204 $status = (isset($_GET['status'])) ? sanitize_key($_GET['status']) : '';
205 $view = (isset($_GET['view'])) ? sanitize_key($_GET['view']) : '';
206 $group_edit_id =(isset($_GET['group'])) ? sanitize_key($_GET['group']) : '';
207
208 if(!is_numeric($status)) $status = 0;
209 if(!is_numeric($group_edit_id)) $group_edit_id = 0;
210
211 if(isset($_GET['month']) AND isset($_GET['year'])) {
212 $month = sanitize_key($_GET['month']);
213 $year = sanitize_key($_GET['year']);
214 } else {
215 $month = date('m');
216 $year = date('Y');
217 }
218 $monthstart = mktime(0, 0, 0, $month, 1, $year);
219 $monthend = mktime(0, 0, 0, $month+1, 0, $year);
220
221 $today = adrotate_date_start('day');
222 $now = current_time('timestamp');
223 $today = adrotate_date_start('day');
224 $in2days = $now + 172800;
225 $in7days = $now + 604800;
226 ?>
227 <div class="wrap">
228 <h1><?php _e("Manage Groups", 'adrotate'); ?></h1>
229
230 <?php if($status > 0) adrotate_status($status); ?>
231
232 <div class="tablenav">
233 <div class="alignleft actions">
234 <a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-groups&view=manage');?>"><?php _e("Manage", 'adrotate'); ?></a>
235 &nbsp;|&nbsp;<a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-groups&view=addnew');?>"><?php _e("Add New", 'adrotate'); ?></a>
236 &nbsp;|&nbsp;<a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-pro');?>"><?php _e("Get AdRotate Pro", 'adrotate'); ?></a>
237 </div>
238 </div>
239
240 <?php
241 if (empty($view) OR $view == 'manage') {
242 include('dashboard/publisher/manage-groups.php');
243 } else if($view == 'addnew' OR $view == 'edit') {
244 include('dashboard/publisher/manage-groups-edit.php');
245 }
246 ?>
247 </div>
248 <?php
249 }
250
251 /*-------------------------------------------------------------
252 Name: adrotate_manage_schedules
253 Purpose: Manage schedules for ads
254 -------------------------------------------------------------*/
255 function adrotate_manage_schedules() {
256 global $wpdb, $adrotate_config;
257
258 $now = current_time('timestamp');
259 $in2days = $now + 172800;
260 ?>
261 <div class="wrap">
262 <h1><?php _e("Manage Schedules", 'adrotate'); ?></h1>
263
264 <?php
265 include('dashboard/publisher/manage-schedules.php');
266 ?>
267 </div>
268 <?php
269 }
270
271 /*-------------------------------------------------------------
272 Name: adrotate_manage_media
273 Purpose: Manage banner images for ads
274 -------------------------------------------------------------*/
275 function adrotate_manage_media() {
276 global $wpdb, $adrotate_config;
277
278 $status = (isset($_GET['status'])) ? sanitize_key($_GET['status']) : '';
279 $file = (isset($_GET['file'])) ? sanitize_file_name($_GET['file']) : '';
280
281 if(!is_numeric($status)) $status = 0;
282
283 if(strlen($file) > 0 AND wp_verify_nonce($_REQUEST['_wpnonce'], 'adrotate_delete_media_'.$file)) {
284 if(adrotate_unlink($file)) {
285 $status = 206;
286 } else {
287 $status = 207;
288 }
289 }
290 ?>
291
292 <div class="wrap">
293 <h1><?php _e("Manage Media and Assets", 'adrotate'); ?></h1>
294
295 <?php if($status > 0) adrotate_status($status); ?>
296
297 <p><?php _e("Upload images to the AdRotate Pro banners folder from here. This is useful if you have HTML5 adverts containing multiple files.", 'adrotate'); ?></p>
298
299 <?php
300 include('dashboard/publisher/media.php');
301 ?>
302 </div>
303 <?php
304 }
305
306 /*-------------------------------------------------------------
307 Name: adrotate_statistics
308 Purpose: Advert and Group stats
309 -------------------------------------------------------------*/
310 function adrotate_statistics() {
311 global $wpdb, $adrotate_config;
312
313 $view = (isset($_GET['view'])) ? sanitize_key($_GET['view']) : '';
314 $status = (isset($_GET['status'])) ? sanitize_key($_GET['status']) : '';
315 $id =(isset($_GET['id'])) ? sanitize_key($_GET['id']) : '';
316 $file = (isset($_GET['file'])) ? sanitize_file_name($_GET['file']) : '';
317
318 if(!is_numeric($status)) $status = 0;
319 if(!is_numeric($id)) $id = 0;
320
321 if(isset($_GET['month']) AND isset($_GET['year'])) {
322 $month = sanitize_key($_GET['month']);
323 $year = sanitize_key($_GET['year']);
324 } else {
325 $month = date('m');
326 $year = date('Y');
327 }
328 $monthstart = gmmktime(0, 0, 0, $month, 1, $year);
329 $monthend = gmmktime(0, 0, 0, $month+1, 0, $year);
330 $today = adrotate_date_start('day');
331 ?>
332 <div class="wrap">
333 <h2><?php _e("Advert Statistics", 'adrotate'); ?></h2>
334
335 <?php
336 if($status > 0) adrotate_status($status, array('file' => $file));
337
338 if(empty($view)) {
339 include('dashboard/publisher/statistics-main.php');
340 } else if($view == 'advert') {
341 include('dashboard/publisher/statistics-advert.php');
342 } else if($view == 'group') {
343 include('dashboard/publisher/statistics-group.php');
344 }
345 ?>
346 </div>
347 <?php
348 }
349
350 /*-------------------------------------------------------------
351 Name: adrotate_support
352 Purpose: Get help
353 -------------------------------------------------------------*/
354 function adrotate_support() {
355 global $wpdb, $adrotate_config;
356
357 $view = (isset($_GET['view'])) ? sanitize_key($_GET['view']) : '';
358 $status = (isset($_GET['status'])) ? sanitize_key($_GET['status']) : '';
359 $file = (isset($_GET['file'])) ? sanitize_file_name($_GET['file']) : '';
360
361 if(!is_numeric($status)) $status = 0;
362
363 $current_user = wp_get_current_user();
364 ?>
365
366 <div class="wrap">
367 <h1><?php _e("AdRotate Support", 'adrotate'); ?></h1>
368
369 <?php
370 if($status > 0) adrotate_status($status);
371
372 include('dashboard/support.php');
373 ?>
374
375 </div>
376 <?php
377 }
378
379 /*-------------------------------------------------------------
380 Name: adrotate_options
381 Purpose: Admin options page
382 -------------------------------------------------------------*/
383 function adrotate_options() {
384 global $wpdb, $wp_roles;
385
386 $active_tab = (isset($_GET['tab'])) ? sanitize_key($_GET['tab']) : 'general';
387 $status = (isset($_GET['status'])) ? sanitize_key($_GET['status']) : '';
388 $action =(isset($_GET['action'])) ? sanitize_key($_GET['action']) : '';
389
390 if(!is_numeric($status)) $status = 0;
391
392 if(isset($_GET['adrotate-nonce']) AND wp_verify_nonce($_GET['adrotate-nonce'], 'maintenance')) {
393 if($action == 'check-all-ads') {
394 adrotate_evaluate_ads();
395 $status = 405;
396 }
397
398 if($action == 'update-db') {
399 adrotate_finish_upgrade();
400 $status = 409;
401 }
402
403 if($action == 'reset-tasks') {
404 adrotate_check_schedules();
405 $status = 407;
406 }
407 }
408 ?>
409
410 <div class="wrap">
411 <h1><?php _e("AdRotate Settings", 'adrotate'); ?></h1>
412
413 <?php if($status > 0) adrotate_status($status); ?>
414
415 <h2 class="nav-tab-wrapper">
416 <a href="?page=adrotate-settings&tab=general" class="nav-tab <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>"><?php _e("General", 'adrotate'); ?></a>
417 <a href="?page=adrotate-settings&tab=notifications" class="nav-tab <?php echo $active_tab == 'notifications' ? 'nav-tab-active' : ''; ?>"><?php _e("Notifications", 'adrotate'); ?></a>
418 <a href="?page=adrotate-settings&tab=stats" class="nav-tab <?php echo $active_tab == 'stats' ? 'nav-tab-active' : ''; ?>"><?php _e("Statistics", 'adrotate'); ?></a>
419 <a href="?page=adrotate-settings&tab=geo" class="nav-tab <?php echo $active_tab == 'geo' ? 'nav-tab-active' : ''; ?>"><?php _e("Geo Targeting", 'adrotate'); ?></a>
420 <a href="?page=adrotate-settings&tab=roles" class="nav-tab <?php echo $active_tab == 'roles' ? 'nav-tab-active' : ''; ?>"><?php _e("Access Roles", 'adrotate'); ?></a>
421 <a href="?page=adrotate-settings&tab=misc" class="nav-tab <?php echo $active_tab == 'misc' ? 'nav-tab-active' : ''; ?>"><?php _e("Miscellaneous", 'adrotate'); ?></a>
422 <a href="?page=adrotate-settings&tab=maintenance" class="nav-tab <?php echo $active_tab == 'maintenance' ? 'nav-tab-active' : ''; ?>"><?php _e("Maintenance", 'adrotate'); ?></a>
423 </h2>
424
425 <?php
426 $adrotate_config = get_option('adrotate_config');
427
428 if($active_tab == 'general') {
429 $adrotate_crawlers = get_option('adrotate_crawlers');
430
431 $crawlers = '';
432 if(is_array($adrotate_crawlers)) {
433 $crawlers = implode(', ', $adrotate_crawlers);
434 }
435
436 include('dashboard/settings/general.php');
437 } elseif($active_tab == 'notifications') {
438 $adrotate_notifications = get_option('adrotate_notifications');
439
440 include('dashboard/settings/notifications.php');
441 } elseif($active_tab == 'stats') {
442 include('dashboard/settings/statistics.php');
443 } elseif($active_tab == 'geo') {
444 include('dashboard/settings/geotargeting.php');
445 } elseif($active_tab == 'roles') {
446 include('dashboard/settings/roles.php');
447 } elseif($active_tab == 'misc') {
448 include('dashboard/settings/misc.php');
449 } elseif($active_tab == 'maintenance') {
450 $adrotate_version = get_option('adrotate_version');
451 $adrotate_db_version = get_option('adrotate_db_version');
452 $advert_status = get_option("adrotate_advert_status");
453
454 $tracker = wp_next_scheduled('adrotate_empty_trackerdata');
455
456 include('dashboard/settings/maintenance.php');
457 }
458 ?>
459 </div>
460 <?php
461 }
462 ?>
463