コード例 #1
0
function adrotate_import_ads()
{
    global $wpdb, $current_user, $userdata;
    if (wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_import')) {
        if (current_user_can('adrotate_ad_manage')) {
            if ($_FILES["adrotate_file"]["error"] == 4) {
                adrotate_return('adrotate-ads', 506, array('view' => 'import'));
                exit;
            } else {
                if ($_FILES["adrotate_file"]["error"] > 0) {
                    adrotate_return('adrotate-ads', 507, array('view' => 'import'));
                    exit;
                } else {
                    if ($_FILES["adrotate_file"]["size"] > 4096000) {
                        adrotate_return('adrotate-ads', 511, array('view' => 'import'));
                        exit;
                    } else {
                        $now = adrotate_now();
                        $ad_fields = array('title', 'bannercode', 'thetime', 'updated', 'author', 'imagetype', 'image', 'tracker', 'responsive', 'type', 'weight', 'sortorder', 'budget', 'crate', 'irate', 'cities', 'countries');
                        if ($_FILES["adrotate_file"]["type"] == "text/xml" or $_FILES["adrotate_file"]["type"] == "application/xml" or $_FILES["adrotate_file"]["type"] == "application/x-xml") {
                            $xml_name = "adrotate_import_" . date_i18n("mdYHi", $now) . ".xml";
                            move_uploaded_file($_FILES["adrotate_file"]["tmp_name"], WP_CONTENT_DIR . "/reports/" . $xml_name);
                            $file = WP_CONTENT_URL . "/reports/" . $xml_name;
                            $xml = simplexml_load_file($file);
                            foreach ($xml->xpath('advert') as $advert) {
                                $ad = array('title' => strip_tags(htmlspecialchars(trim($advert->title, "\t\n "), ENT_QUOTES)), 'bannercode' => htmlspecialchars(trim($advert->bannercode, "\t\n "), ENT_QUOTES), 'thetime' => $now, 'updated' => $now, 'author' => $current_user->user_login, 'imagetype' => strip_tags(trim($advert->imagetype, "\t\n ")), 'image' => strip_tags(trim($advert->image, "\t\n ")), 'tracker' => strip_tags(trim($advert->tracker, "\t\n ")), 'mobile' => strip_tags(trim($advert->mobile, "\t\n ")), 'tablet' => strip_tags(trim($advert->tablet, "\t\n ")), 'responsive' => strip_tags(trim($advert->responsive, "\t\n ")), 'type' => 'import', 'weight' => strip_tags(trim($advert->weight, "\t\n ")), 'sortorder' => 0, 'budget' => strip_tags(trim($advert->budget, "\t\n ")), 'crate' => strip_tags(trim($advert->crate, "\t\n ")), 'irate' => strip_tags(trim($advert->irate, "\t\n ")), 'cities' => serialize(explode(',', strip_tags(trim($advert->cities, "\t\n ")))), 'countries' => serialize(explode(',', strip_tags(trim($advert->countries, "\t\n ")))));
                                $wpdb->insert($wpdb->prefix . "adrotate", $ad);
                                $ad_id = $wpdb->insert_id;
                                $schedule = array('name' => 'Schedule for advert ' . $ad_id, 'starttime' => strip_tags(trim($advert->start, "\t\n ")), 'stoptime' => strip_tags(trim($advert->end, "\t\n ")), 'maxclicks' => 0, 'maximpressions' => 0, 'spread' => 'N', 'dayimpressions' => 0);
                                $wpdb->insert($wpdb->prefix . "adrotate_schedule", $schedule);
                                $schedule_id = $wpdb->insert_id;
                                $linkmeta = array('ad' => $ad_id, 'group' => 0, 'user' => 0, 'schedule' => $schedule_id);
                                $wpdb->insert($wpdb->prefix . "adrotate_linkmeta", $linkmeta);
                                unset($advert, $ad, $ad_id, $schedule, $schedule_id, $linkmeta);
                            }
                        }
                        adrotate_prepare_evaluate_ads(false);
                        // return to dashboard
                        adrotate_return('adrotate-ads', 216);
                        exit;
                    }
                }
            }
        } else {
            adrotate_return('adrotate-ads', 500);
        }
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #2
0
function adrotate_license_deactivate()
{
    if (wp_verify_nonce($_POST['adrotate_nonce_license'], 'adrotate_license')) {
        $network = false;
        if (isset($_POST['adrotate_license_network'])) {
            $network = trim($_POST['adrotate_license_network'], "\t\n ");
        }
        if ($network == 1) {
            $redirect = 'adrotate';
            $a = get_site_option('adrotate_activate');
        } else {
            $redirect = 'adrotate-settings';
            $a = get_option('adrotate_activate');
        }
        $force = isset($_POST['adrotate_license_force']) ? 1 : 0;
        if ($a) {
            adrotate_license_response('deactivation', $a, false, $network, 0, $force);
        }
        adrotate_return($redirect, 600, array('tab' => 'license'));
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #3
0
function adrotate_export_stats()
{
    global $wpdb;
    if (wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_ads') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_groups') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_advertiser') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_report_global')) {
        $id = $type = $month = $year = $adstats = '';
        $id = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_id'], "\t\n "), ENT_QUOTES));
        $type = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_type'], "\t\n "), ENT_QUOTES));
        $month = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_month'], "\t\n "), ENT_QUOTES));
        $year = strip_tags(htmlspecialchars(trim($_POST['adrotate_export_year'], "\t\n "), ENT_QUOTES));
        $csv_emails = trim($_POST['adrotate_export_addresses']);
        if (strlen($csv_emails) > 0) {
            $csv_emails = explode(',', trim($csv_emails));
            foreach ($csv_emails as $csv_email) {
                $csv_email = strip_tags(htmlspecialchars(trim($csv_email), ENT_QUOTES));
                if (strlen($csv_email) > 0) {
                    if (preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}\$/i", $csv_email)) {
                        $clean_advertiser_email[] = $csv_email;
                    }
                }
            }
            $emails = array_unique(array_slice($clean_advertiser_email, 0, 3));
        } else {
            $emails = array();
        }
        $emailcount = count($emails);
        if ($month == 0) {
            $from = mktime(0, 0, 0, 1, 1, $year);
            $until = mktime(0, 0, 0, 12, 31, $year);
        } else {
            $from = mktime(0, 0, 0, $month, 1, $year);
            $until = mktime(0, 0, 0, $month + 1, 0, $year);
        }
        $now = time();
        $from_name = date_i18n("M-d-Y", $from);
        $until_name = date_i18n("M-d-Y", $until);
        $generated = array("Generated on " . date_i18n("M d Y, H:i"));
        if ($type == "single" or $type == "group" or $type == "global") {
            if ($type == "single") {
                $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE (`thetime` >= '" . $from . "' AND `thetime` <= '" . $until . "') AND `ad` = %d GROUP BY `thetime` ASC;", $id), ARRAY_A);
                $title = $wpdb->get_var($wpdb->prepare("SELECT `title` FROM `{$wpdb->prefix}adrotate` WHERE `id` = %d;", $id));
                $filename = "Single-ad ID" . $id . " - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
                $topic = array("Report for ad '" . $title . "'");
                $period = array("Period - From: " . $from_name . " Until: " . $until_name);
                $keys = array("Day", "Clicks", "Impressions");
            }
            if ($type == "group") {
                $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE (`thetime` >= '" . $from . "' AND `thetime` <= '" . $until . "') AND  `group` = %d GROUP BY `thetime` ASC;", $id), ARRAY_A);
                $title = $wpdb->get_var($wpdb->prepare("SELECT `name` FROM `{$wpdb->prefix}adrotate_groups` WHERE `id` = %d;", $id));
                $filename = "Ad Group ID" . $id . " - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
                $topic = array("Report for group '" . $title . "'");
                $period = array("Period - From: " . $from_name . " Until: " . $until_name);
                $keys = array("Day", "Clicks", "Impressions");
            }
            if ($type == "global") {
                $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE `thetime` >= %d AND `thetime` <= %d GROUP BY `thetime` ASC;", $from, $until), ARRAY_A);
                $filename = "Global report - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
                $topic = array("Global report");
                $period = array("Period - From: " . $from_name . " Until: " . $until_name);
                $keys = array("Day", "Clicks", "Impressions");
            }
            $x = 0;
            foreach ($ads as $ad) {
                // Prevent gaps in display
                if ($ad['impressions'] == 0) {
                    $ad['impressions'] = 0;
                }
                if ($ad['clicks'] == 0) {
                    $ad['clicks'] = 0;
                }
                // Build array
                $adstats[$x]['day'] = date_i18n("M d Y", $ad['thetime']);
                $adstats[$x]['clicks'] = $ad['clicks'];
                $adstats[$x]['impressions'] = $ad['impressions'];
                $x++;
            }
        }
        if ($type == "advertiser") {
            // Global advertiser stats
            $ads = $wpdb->get_results($wpdb->prepare("SELECT `ad` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `group` = 0 AND `user` = %d ORDER BY `ad` ASC;", $id));
            $x = 0;
            foreach ($ads as $ad) {
                $title = $wpdb->get_var("SELECT `title` FROM `{$wpdb->prefix}adrotate` WHERE `id` = '" . $ad->ad . "';");
                $startshow = $endshow = 0;
                $startshow = $wpdb->get_var("SELECT `starttime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $ad->ad . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `starttime` ASC LIMIT 1;");
                $endshow = $wpdb->get_var("SELECT `stoptime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $ad->ad . "' AND  `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
                $username = $wpdb->get_var($wpdb->prepare("SELECT `display_name` FROM `{$wpdb->users}`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `{$wpdb->users}`.`ID` = `user` AND `ad` = %d ORDER BY `user_nicename` ASC;", $id));
                $stat = adrotate_stats($ad->ad);
                // Prevent gaps in display
                if ($stat['impressions'] == 0 and $stat['clicks'] == 0) {
                    $ctr = "0";
                } else {
                    $ctr = round(100 / $stat['impressions'] * $stat['clicks'], 2);
                }
                // Build array
                $adstats[$x]['title'] = $title;
                $adstats[$x]['id'] = $ad->ad;
                $adstats[$x]['startshow'] = date_i18n("M d Y", $startshow);
                $adstats[$x]['endshow'] = date_i18n("M d Y", $endshow);
                $adstats[$x]['clicks'] = $stat['clicks'];
                $adstats[$x]['impressions'] = $stat['impressions'];
                $adstats[$x]['ctr'] = $ctr;
                $x++;
            }
            $filename = "Advertiser - " . $username . " - export.csv";
            $topic = array("Advertiser report for " . $username);
            $period = array("Period - Not Applicable");
            $keys = array("Title", "Ad ID", "First visibility", "Last visibility", "Clicks", "Impressions", "CTR (%)");
        }
        if ($type == "advertiser-single") {
            // Single advertiser stats
            $ads = $wpdb->get_results($wpdb->prepare("SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `{$wpdb->prefix}adrotate_stats` WHERE (`thetime` >= '{$from}' AND `thetime` <= '{$until}') AND `ad` = %d GROUP BY `thetime` ASC;", $id), ARRAY_A);
            $title = $wpdb->get_var($wpdb->prepare("SELECT `title` FROM `{$wpdb->prefix}adrotate` WHERE `id` = %d;", $id));
            $username = $wpdb->get_var($wpdb->prepare("SELECT `display_name` FROM `{$wpdb->users}`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `{$wpdb->users}`.`ID` = `user` AND `ad` = %d ORDER BY `user_nicename` ASC;", $id));
            $filename = "Single-ad ID" . $id . " - " . $from_name . " to " . $until_name . " - exported " . $now . ".csv";
            $topic = array("Advertiser report for " . $username . " for ad '" . $title . "'");
            $period = array("Period - From: " . $from_name . " Until: " . $until_name);
            $keys = array("Day", "Clicks", "Impressions");
            $x = 0;
            foreach ($ads as $ad) {
                // Prevent gaps in display
                if ($ad['impressions'] == 0) {
                    $ad['impressions'] = 0;
                }
                if ($ad['clicks'] == 0) {
                    $ad['clicks'] = 0;
                }
                // Build array
                $adstats[$x]['day'] = date_i18n("M d Y", $ad['thetime']);
                $adstats[$x]['clicks'] = $ad['clicks'];
                $adstats[$x]['impressions'] = $ad['impressions'];
                $x++;
            }
        }
        if ($adstats) {
            if (!file_exists(WP_CONTENT_DIR . '/reports/')) {
                mkdir(WP_CONTENT_DIR . '/reports/', 0755);
            }
            $fp = fopen(WP_CONTENT_DIR . '/reports/' . $filename, 'w');
            if ($fp) {
                fputcsv($fp, $topic);
                fputcsv($fp, $period);
                fputcsv($fp, $generated);
                fputcsv($fp, $keys);
                foreach ($adstats as $stat) {
                    fputcsv($fp, $stat);
                }
                fclose($fp);
                if ($emailcount > 0) {
                    $attachments = array(WP_CONTENT_DIR . '/reports/' . $filename);
                    $siteurl = get_option('siteurl');
                    $email = get_option('admin_email');
                    $headers = "MIME-Version: 1.0\r\n" . "From: AdRotate Plugin <" . $email . ">\r\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\r\n";
                    $subject = __('[AdRotate] CSV Report!', 'adrotate-pro');
                    $message = "<p>" . __('Hello', 'adrotate-pro') . ",</p>";
                    $message .= "<p>" . __('Attached in this email you will find the exported CSV file you generated on ', 'adrotate-pro') . " {$siteurl}.</p>";
                    $message .= "<p>" . __('Have a nice day!', 'adrotate-pro') . "<br />";
                    $message .= __('Your AdRotate Notifier', 'adrotate-pro') . "<br />";
                    $message .= "https://ajdg.solutions/products/adrotate-for-wordpress/</p>";
                    wp_mail($emails, $subject, $message, $headers, $attachments);
                    if ($type == "single") {
                        adrotate_return('adrotate-ads', 212, array('view' => 'report', 'ad' => $id));
                    }
                    if ($type == "group") {
                        adrotate_return('adrotate-groups', 212, array('view' => 'report', 'group' => $id));
                    }
                    if ($type == "global") {
                        adrotate_return('adrotate-ads', 212, array('view' => 'fullreport'));
                    }
                    if ($type == "advertiser") {
                        adrotate_return('adrotate-advertiser', 303);
                    }
                    if ($type == "advertiser-single") {
                        adrotate_return('adrotate-advertiser', 303, array('view' => 'report', 'ad' => $id));
                    }
                    exit;
                }
                if ($type == "single") {
                    adrotate_return('adrotate-ads', 215, array('view' => 'report', 'ad' => $id, 'file' => $filename));
                }
                if ($type == "group") {
                    adrotate_return('adrotate-groups', 215, array('view' => 'report', 'group' => $id, 'file' => $filename));
                }
                if ($type == "global") {
                    adrotate_return('adrotate-ads', 215, array('view' => 'fullreport', 'file' => $filename));
                }
                if ($type == "advertiser") {
                    adrotate_return('adrotate-advertiser', 215, array('file' => $filename));
                }
                if ($type == "advertiser-single") {
                    adrotate_return('adrotate-advertiser', 215, array('view' => 'report', 'ad' => $id, 'file' => $filename));
                }
                exit;
            } else {
                if ($type == "single") {
                    adrotate_return('adrotate-ads', 507, array('view' => 'report', 'ad' => $id));
                }
                if ($type == "group") {
                    adrotate_return('adrotate-groups', 507, array('view' => 'report', 'group' => $id));
                }
                if ($type == "global") {
                    adrotate_return('adrotate-ads', 507, array('view' => 'fullreport'));
                }
                if ($type == "advertiser") {
                    adrotate_return('adrotate-advertiser', 507);
                }
                if ($type == "advertiser-single") {
                    adrotate_return('adrotate-advertiser', 507, array('view' => 'report', 'ad' => $id));
                }
            }
        } else {
            if ($type == "single") {
                adrotate_return('adrotate-ads', 503, array('view' => 'report', 'ad' => $id));
            }
            if ($type == "group") {
                adrotate_return('adrotate-groups', 503, array('view' => 'report', 'group' => $id));
            }
            if ($type == "global") {
                adrotate_return('adrotate-ads', 503, array('view' => 'fullreport'));
            }
            if ($type == "advertiser") {
                adrotate_return('adrotate-advertiser', 503);
            }
            if ($type == "advertiser-single") {
                adrotate_return('adrotate-advertiser', 503, array('view' => 'report', 'ad' => $id));
            }
        }
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #4
0
function adrotate_options_submit()
{
    if (wp_verify_nonce($_POST['adrotate_nonce_settings'], 'adrotate_settings')) {
        $settings_tab = esc_attr($_POST['adrotate_settings_tab']);
        if ($settings_tab == 'general') {
            $config = get_option('adrotate_config');
            $config['jquery'] = isset($_POST['adrotate_jquery']) ? 'Y' : 'N';
            $config['jsfooter'] = isset($_POST['adrotate_jsfooter']) ? 'Y' : 'N';
            // Turn options off. Available in AdRotate Pro only
            $config['banner_folder'] = "wp-content/banners/";
            $config['notification_email'] = array();
            $config['advertiser_email'] = array();
            $config['adblock'] = 'N';
            $config['adblock_timer'] = 0;
            $config['adblock_message'] = '';
            $config['enable_geo'] = 0;
            $config['geo_cookie_life'] = 86400;
            $config['geo_email'] = '';
            $config['geo_pass'] = '';
            $config['enable_advertisers'] = 'N';
            $config['enable_editing'] = 'N';
            $config['enable_geo_advertisers'] = 0;
            $config['adblock'] = 'N';
            $config['adblock_loggedin'] = 'N';
            $config['adblock_timer'] = 5;
            $config['adblock_message'] = "Ad blocker detected! Please wait %time% seconds or disable your ad blocker!";
            update_option('adrotate_config', $config);
            // Sort out crawlers
            $crawlers = explode(',', trim($_POST['adrotate_crawlers']));
            $new_crawlers = array();
            foreach ($crawlers as $crawler) {
                $crawler = preg_replace('/[^a-zA-Z0-9\\[\\]\\-_:; ]/i', '', trim($crawler));
                if (strlen($crawler) > 0) {
                    $new_crawlers[] = $crawler;
                }
            }
            update_option('adrotate_crawlers', $new_crawlers);
            $notifications = get_option('adrotate_notifications');
            // Turn options off. Available in AdRotate Pro only
            $notifications['notification_email'] = 'N';
            $notifications['notification_push'] = 'N';
            $notifications['notification_dashboard'] = 'Y';
            $notifications['notification_email_publisher'] = array();
            $notifications['notification_email_advertiser'] = array(get_option('admin_email'));
            $notifications['notification_push_geo'] = 'N';
            $notifications['notification_push_status'] = 'N';
            $notifications['notification_push_queue'] = 'N';
            $notifications['notification_push_approved'] = 'N';
            $notifications['notification_push_rejected'] = 'N';
            $notifications['notification_push_user'] = '';
            $notifications['notification_push_api'] = '';
            update_option('adrotate_notifications', $notifications);
        }
        if ($settings_tab == 'stats') {
            $config = get_option('adrotate_config');
            $stats = trim($_POST['adrotate_stats']);
            $config['stats'] = (is_numeric($stats) and $stats >= 0 and $stats <= 3) ? $stats : 1;
            $config['enable_loggedin_impressions'] = 'Y';
            $config['enable_loggedin_clicks'] = 'Y';
            $impression_timer = trim($_POST['adrotate_impression_timer']);
            $config['impression_timer'] = (is_numeric($impression_timer) and $impression_timer >= 10 and $impression_timer <= 3600) ? $impression_timer : 60;
            $click_timer = trim($_POST['adrotate_click_timer']);
            $config['click_timer'] = (is_numeric($click_timer) and $click_timer >= 60 and $click_timer <= 86400) ? $click_timer : 86400;
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'roles') {
            $config = get_option('adrotate_config');
            adrotate_set_capability($_POST['adrotate_ad_manage'], "adrotate_ad_manage");
            adrotate_set_capability($_POST['adrotate_ad_delete'], "adrotate_ad_delete");
            adrotate_set_capability($_POST['adrotate_group_manage'], "adrotate_group_manage");
            adrotate_set_capability($_POST['adrotate_group_delete'], "adrotate_group_delete");
            $config['ad_manage'] = $_POST['adrotate_ad_manage'];
            $config['ad_delete'] = $_POST['adrotate_ad_delete'];
            $config['group_manage'] = $_POST['adrotate_group_manage'];
            $config['group_delete'] = $_POST['adrotate_group_delete'];
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'misc') {
            $config = get_option('adrotate_config');
            $config['widgetalign'] = isset($_POST['adrotate_widgetalign']) ? 'Y' : 'N';
            $config['widgetpadding'] = isset($_POST['adrotate_widgetpadding']) ? 'Y' : 'N';
            $config['adminbar'] = isset($_POST['adrotate_adminbar']) ? 'Y' : 'N';
            $config['hide_schedules'] = isset($_POST['adrotate_hide_schedules']) ? 'Y' : 'N';
            $config['w3caching'] = isset($_POST['adrotate_w3caching']) ? 'Y' : 'N';
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'maintenance') {
            $debug = get_option('adrotate_debug');
            $debug['general'] = isset($_POST['adrotate_debug']) ? true : false;
            $debug['publisher'] = isset($_POST['adrotate_debug_publisher']) ? true : false;
            $debug['timers'] = isset($_POST['adrotate_debug_timers']) ? true : false;
            $debug['track'] = isset($_POST['adrotate_debug_track']) ? true : false;
            update_option('adrotate_debug', $debug);
        }
        // Return to dashboard
        adrotate_return('adrotate-settings', 400, array('tab' => $settings_tab));
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #5
0
function adrotate_advertiser()
{
    global $wpdb, $current_user, $adrotate_config, $adrotate_debug;
    get_currentuserinfo();
    $status = $view = $ad_edit_id = $request = $request_id = '';
    if (isset($_GET['status'])) {
        $status = esc_attr($_GET['status']);
    }
    if (isset($_GET['view'])) {
        $view = esc_attr($_GET['view']);
    }
    if (isset($_GET['ad'])) {
        $ad_edit_id = esc_attr($_GET['ad']);
    }
    if (isset($_GET['file'])) {
        $filename = esc_attr($_GET['file']);
    }
    if (isset($_GET['request'])) {
        $request = esc_attr($_GET['request']);
    }
    if (isset($_GET['id'])) {
        $request_id = esc_attr($_GET['id']);
    }
    $now = adrotate_now();
    $today = adrotate_date_start('day');
    $in2days = $now + 172800;
    $in7days = $now + 604800;
    $in84days = $now + 7257600;
    if (isset($_GET['month']) and isset($_GET['year'])) {
        $month = esc_attr($_GET['month']);
        $year = esc_attr($_GET['year']);
    } else {
        $month = date("m");
        $year = date("Y");
    }
    $monthstart = mktime(0, 0, 0, $month, 1, $year);
    $monthend = mktime(0, 0, 0, $month + 1, 0, $year);
    ?>
	<div class="wrap">
	  	<h1><?php 
    _e('Advertiser', 'adrotate-pro');
    ?>
</h1>

		<?php 
    if ($status > 0) {
        adrotate_status($status, array('file' => $filename));
    }
    ?>

		<div class="tablenav">
			<div class="alignleft actions">
				<a class="row-title" href="<?php 
    echo admin_url('/admin.php?page=adrotate-advertiser');
    ?>
"><?php 
    _e('Manage', 'adrotate-pro');
    ?>
</a>
				<?php 
    if ($adrotate_config['enable_editing'] == 'Y') {
        ?>
				 | <a class="row-title" href="<?php 
        echo admin_url('/admin.php?page=adrotate-advertiser&view=addnew');
        ?>
"><?php 
        _e('Add New', 'adrotate-pro');
        ?>
</a> 
				<?php 
    }
    ?>
			</div>
		</div>

		<?php 
    $wpnonceaction = 'adrotate_email_advertiser_' . $request_id;
    if ($view == "") {
        $ads = $wpdb->get_results($wpdb->prepare("SELECT `ad` FROM `{$wpdb->prefix}adrotate_linkmeta` WHERE `group` = 0 AND `user` = %d ORDER BY `ad` ASC;", $current_user->ID));
        if ($ads) {
            $activebanners = $queuebanners = $disabledbanners = false;
            foreach ($ads as $ad) {
                $banner = $wpdb->get_row("SELECT `id`, `title`, `type`, `mobile`, `tablet`, `budget`, `crate`, `irate` FROM `{$wpdb->prefix}adrotate` WHERE (`type` = 'active' OR `type` = '2days' OR `type` = '7days' OR `type` = 'disabled' OR `type` = 'error' OR `type` = 'a_error' OR `type` = 'expired' OR `type` = 'queue' OR `type` = 'reject') AND `id` = '" . $ad->ad . "';");
                // Skip if no ad
                if (!$banner) {
                    continue;
                }
                $starttime = $stoptime = 0;
                $starttime = $wpdb->get_var("SELECT `starttime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $banner->id . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `starttime` ASC LIMIT 1;");
                $stoptime = $wpdb->get_var("SELECT `stoptime` FROM `{$wpdb->prefix}adrotate_schedule`, `{$wpdb->prefix}adrotate_linkmeta` WHERE `ad` = '" . $banner->id . "' AND `schedule` = `{$wpdb->prefix}adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
                $type = $banner->type;
                if ($type == 'active' and $stoptime <= $in7days) {
                    $type = '7days';
                }
                if ($type == 'active' and $stoptime <= $in2days) {
                    $type = '2days';
                }
                if ($type == 'active' and $stoptime <= $now) {
                    $type = 'expired';
                }
                if ($type == 'active' or $type == '2days' or $type == '7days' or $type == 'expired') {
                    $activebanners[$banner->id] = array('id' => $banner->id, 'title' => $banner->title, 'type' => $type, 'mobile' => $banner->mobile, 'tablet' => $banner->tablet, 'firstactive' => $starttime, 'lastactive' => $stoptime, 'budget' => $banner->budget, 'crate' => $banner->crate, 'irate' => $banner->irate);
                }
                if ($type == 'disabled') {
                    $disabledbanners[$banner->id] = array('id' => $banner->id, 'title' => $banner->title, 'type' => $type);
                }
                if ($type == 'queue' or $type == 'reject' or $type == 'error' or $type == 'a_error') {
                    $queuebanners[$banner->id] = array('id' => $banner->id, 'title' => $banner->title, 'type' => $type, 'mobile' => $banner->mobile, 'tablet' => $banner->tablet, 'budget' => $banner->budget, 'crate' => $banner->crate, 'irate' => $banner->irate);
                }
            }
            // Show active ads, if any
            if ($activebanners) {
                include "dashboard/advertiser/main.php";
            }
            // Show disabled ads, if any
            if ($disabledbanners) {
                include "dashboard/advertiser/main-disabled.php";
            }
            // Show queued ads, if any
            if ($queuebanners) {
                include "dashboard/advertiser/main-queue.php";
            }
            if ($adrotate_config['stats'] == 1) {
                // Gather data for summary report
                $summary = adrotate_prepare_advertiser_report($current_user->ID, $activebanners);
                include "dashboard/advertiser/main-summary.php";
            }
        } else {
            ?>
				<table class="widefat" style="margin-top: .5em">
					<thead>
						<tr>
							<th><?php 
            _e('Notice', 'adrotate-pro');
            ?>
</th>
						</tr>
					</thead>
					<tbody>
					    <tr>
							<td><?php 
            _e('No ads for user.', 'adrotate-pro');
            ?>
</td>
						</tr>
					</tbody>
				</table>
				<?php 
        }
    } else {
        if ($view == "addnew" or $view == "edit") {
            include "dashboard/advertiser/edit.php";
        } else {
            if ($view == "report") {
                include "dashboard/advertiser/report.php";
            } else {
                if ($view == "message") {
                    if (wp_verify_nonce($_REQUEST['_wpnonce'], $wpnonceaction)) {
                        include "dashboard/advertiser/message.php";
                    } else {
                        adrotate_nonce_error();
                        exit;
                    }
                }
            }
        }
    }
    ?>
		<br class="clear" />

		<?php 
    adrotate_user_notice();
    ?>

		<br class="clear" />
	</div>
<?php 
}
コード例 #6
0
function adrotate_mail_message()
{
    if (wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_email_advertiser') or wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_email_moderator')) {
        $notifications = get_option("adrotate_notifications");
        $id = $_POST['adrotate_id'];
        $request = $_POST['adrotate_request'];
        $author = $_POST['adrotate_username'];
        $useremail = $_POST['adrotate_email'];
        $text = strip_tags(stripslashes(trim($_POST['adrotate_message'], "\t\n ")));
        if (strlen($text) < 1) {
            $text = "";
        }
        $emails = $notifications['notification_email_advertiser'];
        $x = count($emails);
        if ($x == 0) {
            $emails = array(get_option('admin_email'));
        }
        $siteurl = get_option('siteurl');
        $adurl = $siteurl . "/wp-admin/admin.php?page=adrotate-ads&view=edit&ad=" . $id;
        $pluginurl = "https://ajdg.solutions/products/adrotate-for-wordpress/";
        $now = adrotate_now();
        if ($request == "renew") {
            $subject = __('[AdRotate] An advertiser has put in a request for renewal!', 'adrotate-pro');
        }
        if ($request == "remove") {
            $subject = __('[AdRotate] An advertiser wants his ad removed.', 'adrotate-pro');
        }
        if ($request == "other") {
            $subject = __('[AdRotate] An advertiser wrote a comment on his ad!', 'adrotate-pro');
        }
        if ($request == "issue") {
            $subject = __('[AdRotate] An advertiser has a problem!', 'adrotate-pro');
        }
        $message = "<p>Hello,</p>";
        if ($request == "renew") {
            $message .= "<p>{$author} " . __('requests ad', 'adrotate-pro') . " <strong>{$id}</strong> " . __('renewed!', 'adrotate-pro') . "</p>";
        }
        if ($request == "remove") {
            $message .= "<p>{$author} " . __('requests ad', 'adrotate-pro') . " <strong>{$id}</strong> " . __('removed.', 'adrotate-pro') . "</p>";
        }
        if ($request == "other") {
            $message .= "<p>{$author} " . __('has something to say about ad', 'adrotate-pro') . " <strong>{$id}</strong>.</p>";
        }
        if ($request == "issue") {
            $message .= "<p>{$author} " . __('has a problem with AdRotate.', 'adrotate-pro') . "</p>";
        }
        $message .= "<p>" . __('Attached message:', 'adrotate-pro') . " {$text}</p>";
        $message .= "<p>" . __('You can reply to this message to contact', 'adrotate-pro') . " {$author}.<br />";
        if ($request != "issue") {
            $message .= __('Review the ad here:', 'adrotate-pro') . " {$adurl}";
        }
        $message .= "</p>";
        $message .= "<p>" . __('Have a nice day!', 'adrotate-pro') . "<br />";
        $message .= __('Your AdRotate Notifier', 'adrotate-pro') . "<br />";
        $message .= "{$pluginurl}</p>";
        for ($i = 0; $i < $x; $i++) {
            $headers = "Content-Type: text/html; charset=UTF-8" . "\r\n" . "From: {$author} <{$useremail}>" . "\r\n";
            wp_mail($emails[$i], $subject, $message, $headers);
        }
        adrotate_return('adrotate-advertiser', 300);
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #7
0
function adrotate_advertiser_insert_input()
{
    global $wpdb, $adrotate_config;
    if (wp_verify_nonce($_POST['adrotate_nonce'], 'adrotate_save_ad')) {
        // Mandatory
        $id = $author = $title = $bannercode = '';
        if (isset($_POST['adrotate_id'])) {
            $id = $_POST['adrotate_id'];
        }
        if (isset($_POST['adrotate_username'])) {
            $author = $_POST['adrotate_username'];
        }
        if (isset($_POST['adrotate_title'])) {
            $title = strip_tags(htmlspecialchars(trim($_POST['adrotate_title'], "\t\n "), ENT_QUOTES));
        }
        if (isset($_POST['adrotate_bannercode'])) {
            $bannercode = htmlspecialchars(trim($_POST['adrotate_bannercode'], "\t\n "), ENT_QUOTES);
        }
        $thetime = adrotate_now();
        // Schedule and timeframe variables
        $schedules = $groups = $group_array = '';
        if (isset($_POST['scheduleselect'])) {
            $schedules = $_POST['scheduleselect'];
        }
        if (isset($_POST['groupselect'])) {
            $groups = $_POST['groupselect'];
        }
        // GeoTargeting
        $cities = '';
        $countries = array();
        if (isset($_POST['adrotate_geo_cities'])) {
            $cities = trim($_POST['adrotate_geo_cities'], "\t\n ");
        }
        if (isset($_POST['adrotate_geo_countries'])) {
            $countries = $_POST['adrotate_geo_countries'];
        }
        if (isset($_POST['adrotate_geo_westeurope'])) {
            $countries_westeurope = array('AD', 'AT', 'BE', 'DK', 'FR', 'DE', 'GR', 'IS', 'IE', 'IT', 'LI', 'LU', 'MT', 'MC', 'NL', 'NO', 'PT', 'SM', 'ES', 'SE', 'CH', 'VA', 'GB');
        }
        if (isset($_POST['adrotate_geo_easteurope'])) {
            $countries_easteurope = array('AL', 'AM', 'AZ', 'BY', 'BA', 'BG', 'HR', 'CY', 'CZ', 'EE', 'FI', 'GE', 'HU', 'LV', 'LT', 'MK', 'MD', 'PL', 'RO', 'RS', 'SK', 'SI', 'TR', 'UA');
        }
        if (isset($_POST['adrotate_geo_northamerica'])) {
            $countries_northamerica = array('AG', 'BS', 'BB', 'BZ', 'CA', 'CR', 'CU', 'DM', 'DO', 'SV', 'GD', 'GT', 'HT', 'HN', 'JM', 'MX', 'NI', 'PA', 'KN', 'LC', 'VC', 'TT', 'US');
        }
        if (isset($_POST['adrotate_geo_southamerica'])) {
            $countries_southamerica = array('AR', 'BO', 'BR', 'CL', 'CO', 'EC', 'GY', 'PY', 'PE', 'SR', 'UY', 'VE');
        }
        if (isset($_POST['adrotate_geo_southeastasia'])) {
            $countries_southeastasia = array('AU', 'BN', 'KH', 'TL', 'ID', 'LA', 'MY', 'MM', 'NZ', 'PH', 'SG', 'TH', 'VN');
        }
        // Ad options
        $adrotate_image_current = $type = $weight = '';
        if (isset($_POST['adrotate_image_current'])) {
            $adrotate_image_current = strip_tags(htmlspecialchars(trim($_POST['adrotate_image_current'], "\t\n "), ENT_QUOTES));
        }
        if (isset($_POST['adrotate_type'])) {
            $type = strip_tags(htmlspecialchars(trim($_POST['adrotate_type'], "\t\n "), ENT_QUOTES));
        }
        if (isset($_POST['adrotate_desktop'])) {
            $desktop = strip_tags(trim($_POST['adrotate_desktop'], "\t\n "));
        }
        if (isset($_POST['adrotate_mobile'])) {
            $mobile = strip_tags(trim($_POST['adrotate_mobile'], "\t\n "));
        }
        if (isset($_POST['adrotate_tablet'])) {
            $tablet = strip_tags(trim($_POST['adrotate_tablet'], "\t\n "));
        }
        if (isset($_POST['adrotate_weight'])) {
            $weight = $_POST['adrotate_weight'];
        }
        if (current_user_can('adrotate_advertiser')) {
            if (strlen($title) < 1) {
                $title = 'Ad ' . $id;
            }
            if ($_FILES["adrotate_image"]["size"] > 0) {
                $allowedExts = array("jpg", "jpeg", "gif", "png", "flv", "swf");
                $filename = sanitize_file_name(strtolower($_FILES["adrotate_image"]["name"]));
                $extension = explode(".", $_FILES["adrotate_image"]["name"]);
                $extension = end($extension);
                $image_path = ABSPATH . $adrotate_config['banner_folder'];
                if (($_FILES["adrotate_image"]["type"] == "image/gif" or $_FILES["adrotate_image"]["type"] == "image/jpeg" or $_FILES["adrotate_image"]["type"] == "image/pjpeg" or $_FILES["adrotate_image"]["type"] == "image/jpg" or $_FILES["adrotate_image"]["type"] == "image/png" or $_FILES["adrotate_image"]["type"] == "application/x-shockwave-flash" or $_FILES["adrotate_image"]["type"] == "video/x-flv" or $_FILES["adrotate_image"]["size"] <= 512000) and in_array($extension, $allowedExts)) {
                    if ($_FILES["adrotate_image"]["error"] > 0) {
                        if ($_FILES["adrotate_image"]["error"] == 1 or $_FILES["adrotate_image"]["error"] == 2) {
                            $errorcode = __("File size exceeded.", "adrotate");
                        } else {
                            if ($_FILES["adrotate_image"]["error"] == 3) {
                                $errorcode = __("Upload incomplete.", "adrotate");
                            } else {
                                if ($_FILES["adrotate_image"]["error"] == 4) {
                                    $errorcode = __("No file uploaded.", "adrotate");
                                } else {
                                    if ($_FILES["adrotate_image"]["error"] == 6 or $_FILES["adrotate_image"]["error"] == 7) {
                                        $errorcode = __("Could not write file to server.", "adrotate");
                                    } else {
                                        $errorcode = __("An unknown error occured, contact staff.", "adrotate");
                                    }
                                }
                            }
                        }
                        wp_die("<h3>" . __("Something went wrong!", "adrotate") . "</h3><p>" . __("Go back and try again. If the error persists, contact staff.", "adrotate") . "</p><p style='color: #f00;'>" . $errorcode . "</p>");
                    } else {
                        $image_name = $id . "-" . $author . "-" . $thetime . "-" . $filename;
                        move_uploaded_file($_FILES["adrotate_image"]["tmp_name"], $image_path . $image_name);
                    }
                } else {
                    wp_die("<h3>" . __("Something went wrong!", "adrotate") . "</h3><p>" . __("Go back and try again. If the error persists, contact staff.", "adrotate") . "</p><p style='color: #f00;'>" . __("The file was either too large or not in the right format.", "adrotate") . "</p>");
                }
            } else {
                $image_name = $adrotate_image_current;
            }
            // Force image location
            $image = site_url() . "/%folder%" . $image_name;
            // Determine image settings ($image_field has priority!)
            if (strlen($image_name) > 0) {
                $imagetype = "dropdown";
                $image = site_url() . "/%folder%" . $image_name;
            } else {
                $imagetype = "";
                $image = "";
            }
            // Set desktop value
            if (isset($desktop) and strlen($desktop) != 0) {
                $desktop = 'Y';
            } else {
                $desktop = 'N';
            }
            // Set mobile value
            if (isset($mobile) and strlen($mobile) != 0) {
                $mobile = 'Y';
            } else {
                $mobile = 'N';
            }
            // Set tablet value
            if (isset($tablet) and strlen($tablet) != 0) {
                $tablet = 'Y';
            } else {
                $tablet = 'N';
            }
            // Geo Targeting
            if (strlen($cities) > 0) {
                $cities = explode(",", strtolower($cities));
                foreach ($cities as $key => $value) {
                    $cities_clean[] = trim($value);
                    unset($value);
                }
                unset($cities);
                $cities = serialize($cities_clean);
            }
            $countries = array_merge($countries, $countries_westeurope, $countries_easteurope, $countries_northamerica, $countries_southamerica, $countries_southeastasia);
            $countries = array_unique($countries);
            if (count($countries) == 0) {
                $countries = serialize(array());
            } else {
                foreach ($countries as $key => $value) {
                    $countries_clean[] = trim($value);
                    unset($value);
                }
                unset($countries);
                $countries = serialize($countries_clean);
            }
            // Fetch schedules for the ad
            $schedulemeta = $wpdb->get_results($wpdb->prepare("SELECT `schedule` FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = %d AND `group` = 0 AND `user` = 0;", $id));
            $schedule_array = array();
            foreach ($schedulemeta as $meta) {
                $schedule_array[] = $meta->schedule;
                unset($meta);
            }
            // Add new schedules to this ad
            if (!is_array($schedules)) {
                $schedules = array();
            }
            $insert = array_diff($schedules, $schedule_array);
            foreach ($insert as &$value) {
                $wpdb->insert($wpdb->prefix . 'adrotate_linkmeta', array('ad' => $id, 'group' => 0, 'user' => 0, 'schedule' => $value));
            }
            unset($insert, $value);
            // Remove schedules from this ad
            $delete = array_diff($schedule_array, $schedules);
            foreach ($delete as &$value) {
                $wpdb->query($wpdb->prepare("DELETE FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = %d AND `group` = 0 AND `user` = 0 AND `schedule` = %d;", $id, $value));
            }
            unset($delete, $value, $schedulemeta, $schedule_array);
            // Fetch group records for the ad
            $groupmeta = $wpdb->get_results($wpdb->prepare("SELECT `group` FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = %d AND `user` = 0 AND `schedule` = 0;", $id));
            $group_array = array();
            foreach ($groupmeta as $meta) {
                $group_array[] = $meta->group;
                unset($meta);
            }
            // Add new groups to this ad
            if (!is_array($groups)) {
                $groups = array();
            }
            $insert = array_diff($groups, $group_array);
            foreach ($insert as &$value) {
                $wpdb->insert($wpdb->prefix . 'adrotate_linkmeta', array('ad' => $id, 'group' => $value, 'user' => 0, 'schedule' => 0));
            }
            unset($insert, $value);
            // Remove groups from this ad
            $delete = array_diff($group_array, $groups);
            foreach ($delete as &$value) {
                $wpdb->query($wpdb->prepare("DELETE FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = %d AND `group` = %d AND `user` = 0 AND `schedule` = 0;", $id, $value));
            }
            unset($delete, $value, $groupmeta, $group_array);
            // Save the ad to the DB
            $wpdb->update($wpdb->prefix . 'adrotate', array('title' => $title, 'bannercode' => $bannercode, 'updated' => $thetime, 'author' => $author, 'imagetype' => $imagetype, 'image' => $image, 'desktop' => $desktop, 'mobile' => $mobile, 'tablet' => $tablet, 'weight' => $weight, 'cities' => $cities, 'countries' => $countries), array('id' => $id));
            // Determine status of ad
            $adstate = adrotate_evaluate_ad($id);
            if ($adstate == 'error' or $adstate == 'expired') {
                $action = 502;
                $active = 'a_error';
            } else {
                $action = 306;
                $active = 'queue';
            }
            $wpdb->update($wpdb->prefix . 'adrotate', array('type' => $active), array('id' => $id));
            if ($action == 306) {
                adrotate_push_notifications('queued', $id);
            }
            // Fetch records for the ad, see if a publisher is set
            $linkmeta = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = %d AND `group` = 0 AND `user` > 0;", $id));
            $advertiser = wp_get_current_user();
            // Add/update publisher on this ad
            if ($linkmeta == 0 and $advertiser->ID > 0) {
                $wpdb->insert($wpdb->prefix . 'adrotate_linkmeta', array('ad' => $id, 'group' => 0, 'user' => $advertiser->ID, 'schedule' => 0));
            }
            if ($linkmeta == 1 and $advertiser->ID > 0) {
                $wpdb->query($wpdb->prepare("UPDATE `" . $wpdb->prefix . "adrotate_linkmeta` SET `user` = {$advertiser->ID} WHERE `ad` = %d AND `group` = 0 AND `schedule` = 0;", $id));
            }
            adrotate_return('adrotate-advertiser', $action);
            exit;
        } else {
            adrotate_return('adrotate-advertiser', 500);
        }
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #8
0
function adrotate_options_submit()
{
    if (wp_verify_nonce($_POST['adrotate_nonce_settings'], 'adrotate_settings')) {
        $settings_tab = esc_attr($_POST['adrotate_settings_tab']);
        if ($settings_tab == 'general') {
            $config = get_option('adrotate_config');
            $config['textwidget_shortcodes'] = isset($_POST['adrotate_textwidget_shortcodes']) ? 'Y' : 'N';
            $config['live_preview'] = isset($_POST['adrotate_live_preview']) ? 'Y' : 'N';
            $config['mobile_dynamic_mode'] = isset($_POST['adrotate_mobile_dynamic_mode']) ? 'Y' : 'N';
            $config['jquery'] = isset($_POST['adrotate_jquery']) ? 'Y' : 'N';
            $config['jsfooter'] = isset($_POST['adrotate_jsfooter']) ? 'Y' : 'N';
            $adblock_disguise = strtolower(trim($_POST['adrotate_adblock_disguise']));
            $config['adblock_disguise'] = strlen($adblock_disguise) > 0 ? preg_replace('/[^a-z]/', '', strtolower(substr($adblock_disguise, 0, 6))) : "";
            $banner_folder = strtolower(trim($_POST['adrotate_banner_folder']));
            $config['banner_folder'] = strlen($banner_folder) > 0 ? preg_replace('/[^a-zA-Z0-9\\/\\-_]/', '', $banner_folder) : "wp-content/banners/";
            $config['adblock'] = isset($_POST['adrotate_adblock']) ? 'Y' : 'N';
            $config['adblock_loggedin'] = isset($_POST['adrotate_adblock_loggedin']) ? 'Y' : 'N';
            $adblock_timer = trim($_POST['adrotate_adblock_timer']);
            $config['adblock_timer'] = (strlen($adblock_timer) > 0 and (is_numeric($adblock_timer) and $adblock_timer >= 1 and $adblock_timer <= 20)) ? $adblock_timer : 5;
            $adblock_message = trim($_POST['adrotate_adblock_message']);
            $config['adblock_message'] = strlen($adblock_message) > 0 ? strip_tags(htmlspecialchars(trim($adblock_message, "\t\n "), ENT_QUOTES)) : "Ad blocker detected! Please wait %time% seconds or disable your ad blocker!";
            update_option('adrotate_config', $config);
            // Sort out crawlers
            $crawlers = explode(',', trim($_POST['adrotate_crawlers']));
            $new_crawlers = array();
            foreach ($crawlers as $crawler) {
                $crawler = preg_replace('/[^a-zA-Z0-9\\[\\]\\-_:; ]/i', '', trim($crawler));
                if (strlen($crawler) > 0) {
                    $new_crawlers[] = $crawler;
                }
            }
            update_option('adrotate_crawlers', $new_crawlers);
        }
        if ($settings_tab == 'notifications') {
            $notifications = get_option('adrotate_notifications');
            // Notifications
            $notifications['notification_email'] = isset($_POST['adrotate_notification_email']) ? 'Y' : 'N';
            $notifications['notification_push'] = isset($_POST['adrotate_notification_push']) ? 'Y' : 'N';
            $notifications['notification_dashboard'] = isset($_POST['adrotate_notification_dashboard']) ? 'N' : 'Y';
            // Filter and validate notification addresses, if not set, turn option off.
            $notification_emails = $_POST['adrotate_notification_email_publisher'];
            if (strlen($notification_emails) > 0) {
                $notification_emails = explode(',', trim($notification_emails));
                foreach ($notification_emails as $notification_email) {
                    $notification_email = trim($notification_email);
                    if (strlen($notification_email) > 0) {
                        if (is_email($notification_email)) {
                            $clean_notification_email[] = $notification_email;
                        }
                    }
                }
                $notifications['notification_email_publisher'] = array_unique(array_slice($clean_notification_email, 0, 5));
            } else {
                $notifications['notification_email_publisher'] = array();
            }
            // Filter and validate advertiser addresses
            $advertiser_emails = $_POST['adrotate_notification_email_advertiser'];
            if (strlen($advertiser_emails) > 0) {
                $advertiser_emails = explode(',', trim($advertiser_emails));
                foreach ($advertiser_emails as $advertiser_email) {
                    $advertiser_email = trim($advertiser_email);
                    if (strlen($advertiser_email) > 0) {
                        if (is_email($advertiser_email)) {
                            $clean_advertiser_email[] = $advertiser_email;
                        }
                    }
                }
                $notifications['notification_email_advertiser'] = array_unique(array_slice($clean_advertiser_email, 0, 2));
            } else {
                $notifications['notification_email_advertiser'] = array(get_option('admin_email'));
            }
            // Push Notifications
            $notifications['notification_push_geo'] = isset($_POST['adrotate_notification_push_geo']) ? 'Y' : 'N';
            $notifications['notification_push_status'] = isset($_POST['adrotate_notification_push_status']) ? 'Y' : 'N';
            $notifications['notification_push_queue'] = isset($_POST['adrotate_notification_push_queue']) ? 'Y' : 'N';
            $notifications['notification_push_approved'] = isset($_POST['adrotate_notification_push_approved']) ? 'Y' : 'N';
            $notifications['notification_push_rejected'] = isset($_POST['adrotate_notification_push_rejected']) ? 'Y' : 'N';
            $notifications['notification_push_user'] = strlen($_POST['adrotate_notification_push_user']) > 0 ? preg_replace('/[^a-z0-9.]+/i', '', trim(esc_attr($_POST['adrotate_notification_push_user']))) : '';
            $notifications['notification_push_api'] = strlen($_POST['adrotate_notification_push_api']) > 0 ? preg_replace('/[^a-z0-9.]+/i', '', trim(esc_attr($_POST['adrotate_notification_push_api']))) : '';
            update_option('adrotate_notifications', $notifications);
        }
        if ($settings_tab == 'stats') {
            $config = get_option('adrotate_config');
            $stats = trim($_POST['adrotate_stats']);
            $config['stats'] = (is_numeric($stats) and $stats >= 0 and $stats <= 3) ? $stats : 1;
            $config['enable_loggedin_impressions'] = isset($_POST['adrotate_enable_loggedin_impressions']) ? 'Y' : 'N';
            $config['enable_loggedin_clicks'] = isset($_POST['adrotate_enable_loggedin_clicks']) ? 'Y' : 'N';
            $impression_timer = trim($_POST['adrotate_impression_timer']);
            $config['impression_timer'] = (is_numeric($impression_timer) and $impression_timer >= 10 and $impression_timer <= 3600) ? $impression_timer : 60;
            $click_timer = trim($_POST['adrotate_click_timer']);
            $config['click_timer'] = (is_numeric($click_timer) and $click_timer >= 60 and $click_timer <= 86400) ? $click_timer : 86400;
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'geo') {
            $config = get_option('adrotate_config');
            $geo = trim($_POST['adrotate_enable_geo']);
            $config['enable_geo'] = (is_numeric($geo) and $geo >= 0 and $geo <= 5) ? $geo : 0;
            $geo_cookie = trim($_POST['adrotate_geo_cookie_life']);
            $config['geo_cookie_life'] = is_numeric($geo_cookie) ? $geo_cookie : 86400;
            $geo_email = trim($_POST['adrotate_geo_email']);
            $config['geo_email'] = strlen($geo_email) > 0 ? $geo_email : '';
            $geo_pass = trim($_POST['adrotate_geo_pass']);
            $config['geo_pass'] = strlen($geo_pass) > 0 ? $geo_pass : '';
            // Try to update the Geo Cookie for Admin
            if ($config['enable_geo'] > 0) {
                adrotate_geolocation();
            }
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'advertisers') {
            $config = get_option('adrotate_config');
            $config['enable_advertisers'] = isset($_POST['adrotate_enable_advertisers']) ? 'Y' : 'N';
            $config['enable_editing'] = isset($_POST['adrotate_enable_editing']) ? 'Y' : 'N';
            $config['enable_mobile_advertisers'] = isset($_POST['adrotate_enable_mobile_advertisers']) ? 1 : 0;
            $config['enable_geo_advertisers'] = isset($_POST['adrotate_enable_geo_advertisers']) ? 1 : 0;
            if (isset($_POST['adrotate_role'])) {
                adrotate_prepare_roles('add');
            } else {
                adrotate_prepare_roles('remove');
            }
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'roles') {
            $config = get_option('adrotate_config');
            adrotate_set_capability($_POST['adrotate_advertiser'], "adrotate_advertiser");
            adrotate_set_capability($_POST['adrotate_global_report'], "adrotate_global_report");
            adrotate_set_capability($_POST['adrotate_ad_manage'], "adrotate_ad_manage");
            adrotate_set_capability($_POST['adrotate_ad_delete'], "adrotate_ad_delete");
            adrotate_set_capability($_POST['adrotate_group_manage'], "adrotate_group_manage");
            adrotate_set_capability($_POST['adrotate_group_delete'], "adrotate_group_delete");
            adrotate_set_capability($_POST['adrotate_schedule_manage'], "adrotate_schedule_manage");
            adrotate_set_capability($_POST['adrotate_schedule_delete'], "adrotate_schedule_delete");
            adrotate_set_capability($_POST['adrotate_moderate'], "adrotate_moderate");
            adrotate_set_capability($_POST['adrotate_moderate_approve'], "adrotate_moderate_approve");
            $config['advertiser'] = $_POST['adrotate_advertiser'];
            $config['global_report'] = $_POST['adrotate_global_report'];
            $config['ad_manage'] = $_POST['adrotate_ad_manage'];
            $config['ad_delete'] = $_POST['adrotate_ad_delete'];
            $config['group_manage'] = $_POST['adrotate_group_manage'];
            $config['group_delete'] = $_POST['adrotate_group_delete'];
            $config['schedule_manage'] = $_POST['adrotate_schedule_manage'];
            $config['schedule_delete'] = $_POST['adrotate_schedule_delete'];
            $config['moderate'] = $_POST['adrotate_moderate'];
            $config['moderate_approve'] = $_POST['adrotate_moderate_approve'];
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'misc') {
            $config = get_option('adrotate_config');
            $config['widgetalign'] = isset($_POST['adrotate_widgetalign']) ? 'Y' : 'N';
            $config['widgetpadding'] = isset($_POST['adrotate_widgetpadding']) ? 'Y' : 'N';
            $config['adminbar'] = isset($_POST['adrotate_adminbar']) ? 'Y' : 'N';
            $config['hide_schedules'] = isset($_POST['adrotate_hide_schedules']) ? 'Y' : 'N';
            $config['w3caching'] = isset($_POST['adrotate_w3caching']) ? 'Y' : 'N';
            update_option('adrotate_config', $config);
        }
        if ($settings_tab == 'maintenance') {
            $debug = get_option('adrotate_debug');
            $debug['general'] = isset($_POST['adrotate_debug']) ? true : false;
            $debug['publisher'] = isset($_POST['adrotate_debug_publisher']) ? true : false;
            $debug['advertiser'] = isset($_POST['adrotate_debug_advertiser']) ? true : false;
            $debug['geo'] = isset($_POST['adrotate_debug_geo']) ? true : false;
            $debug['timers'] = isset($_POST['adrotate_debug_timers']) ? true : false;
            $debug['track'] = isset($_POST['adrotate_debug_track']) ? true : false;
            update_option('adrotate_debug', $debug);
        }
        // Return to dashboard
        adrotate_return('adrotate-settings', 400, array('tab' => $settings_tab));
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #9
0
ファイル: update-api.php プロジェクト: OneTimeUser/retailwire
function adrotate_support_request()
{
    if (wp_verify_nonce($_POST['ajdg_nonce_support'], 'ajdg_nonce_support_request')) {
        $author = sanitize_text_field($_POST['ajdg_support_username']);
        $useremail = sanitize_email($_POST['ajdg_support_email']);
        $subject = sanitize_text_field($_POST['ajdg_support_subject']);
        $text = esc_attr($_POST['ajdg_support_message']);
        if (adrotate_is_networked()) {
            $a = get_site_option('adrotate_activate');
            $networked = 'Yes';
        } else {
            $a = get_option('adrotate_activate');
            $networked = 'No';
        }
        if (strlen($text) < 1 or strlen($subject) < 1 or strlen($author) < 1 or strlen($useremail) < 1) {
            adrotate_return('adrotate', 505);
        } else {
            $website = get_bloginfo('wpurl');
            $pluginversion = ADROTATE_DISPLAY;
            $wpversion = get_bloginfo('version');
            $wpmultisite = is_multisite() ? 'Yes' : 'No';
            $pluginnetwork = $networked;
            $wplanguage = get_bloginfo('language');
            $wpcharset = get_bloginfo('charset');
            $subject = "[AdRotate Pro Support] {$subject}";
            $message = "<p>Hello,</p>";
            $message .= "<p>{$author} has a question about AdRotate</p>";
            $message .= "<p>{$text}</p>";
            $message .= "<p><strong>Additional information:</strong><br />";
            $message .= "Website: {$website}<br />";
            $message .= "Plugin version: {$pluginversion}<br />";
            $message .= "WordPress version: {$wpversion}<br />";
            $message .= "Is multisite? {$wpmultisite}<br />";
            $message .= "Is networked? {$pluginnetwork}<br />";
            $message .= "Language: {$wplanguage}<br />";
            $message .= "Charset: {$wpcharset}";
            $message .= "</p>";
            $message .= "<p>You can reply to this message to contact {$author}.</p>";
            $message .= "<p>Have a nice day!<br />AdRotate Support</p>";
            $headers[] = "Content-Type: text/html; charset=UTF-8";
            $headers[] = "Reply-To: {$useremail}";
            wp_mail('*****@*****.**', $subject, $message, $headers);
            adrotate_return('adrotate', 701);
            exit;
        }
    } else {
        adrotate_nonce_error();
        exit;
    }
}
コード例 #10
0
function adrotate_options_submit()
{
    if (wp_verify_nonce($_POST['adrotate_nonce_settings'], 'adrotate_settings')) {
        // Set and save user roles
        adrotate_set_capability($_POST['adrotate_ad_manage'], "adrotate_ad_manage");
        adrotate_set_capability($_POST['adrotate_ad_delete'], "adrotate_ad_delete");
        adrotate_set_capability($_POST['adrotate_group_manage'], "adrotate_group_manage");
        adrotate_set_capability($_POST['adrotate_group_delete'], "adrotate_group_delete");
        $config['ad_manage'] = $_POST['adrotate_ad_manage'];
        $config['ad_delete'] = $_POST['adrotate_ad_delete'];
        $config['group_manage'] = $_POST['adrotate_group_manage'];
        $config['group_delete'] = $_POST['adrotate_group_delete'];
        // Enable stats
        $stats = trim($_POST['adrotate_stats']);
        if (is_numeric($stats) and $stats >= 0 and $stats <= 2) {
            $config['stats'] = $stats;
        } else {
            $config['stats'] = 1;
        }
        // Set the banner folder, reset if empty
        $config['banner_folder'] = "wp-content/banners/";
        // Turn option off.
        $config['notification_email_switch'] = 'N';
        $config['notification_email'] = array();
        $config['advertiser_email'] = array();
        // Set up impression tracker timer
        $impression_timer = trim($_POST['adrotate_impression_timer']);
        if (is_numeric($impression_timer) and $impression_timer >= 10 and $impression_timer <= 3600) {
            $config['impression_timer'] = $impression_timer;
        } else {
            $config['impression_timer'] = 60;
        }
        // Set up click timer
        $click_timer = trim($_POST['adrotate_click_timer']);
        if (is_numeric($click_timer) and $click_timer >= 60 and $click_timer <= 86400) {
            $config['click_timer'] = $click_timer;
        } else {
            $config['click_timer'] = 86400;
        }
        // Miscellaneous Options
        if (isset($_POST['adrotate_widgetalign'])) {
            $config['widgetalign'] = 'Y';
        } else {
            $config['widgetalign'] = 'N';
        }
        if (isset($_POST['adrotate_widgetpadding'])) {
            $config['widgetpadding'] = 'Y';
        } else {
            $config['widgetpadding'] = 'N';
        }
        if (isset($_POST['adrotate_w3caching'])) {
            $config['w3caching'] = 'Y';
        } else {
            $config['w3caching'] = 'N';
        }
        if (isset($_POST['adrotate_supercache'])) {
            $config['supercache'] = 'Y';
        } else {
            $config['supercache'] = 'N';
        }
        if (isset($_POST['adrotate_jquery'])) {
            $config['jquery'] = 'Y';
        } else {
            $config['jquery'] = 'N';
        }
        if (isset($_POST['adrotate_jsfooter'])) {
            $config['jsfooter'] = 'Y';
        } else {
            $config['jsfooter'] = 'N';
        }
        $config['adblock'] = 'N';
        // Pro only
        $config['adblock_timer'] = 0;
        // Pro only
        $config['adblock_message'] = '';
        // Pro only
        update_option('adrotate_config', $config);
        // Sort out crawlers
        $crawlers = explode(',', trim($_POST['adrotate_crawlers']));
        $clean_crawler = array();
        foreach ($crawlers as $crawler) {
            $crawler = preg_replace('/[^a-zA-Z0-9\\[\\]\\-_:; ]/i', '', trim($crawler));
            if (strlen($crawler) > 0) {
                $clean_crawler[] = $crawler;
            }
        }
        update_option('adrotate_crawlers', $clean_crawler);
        // Debug option
        if (isset($_POST['adrotate_debug'])) {
            $debug['general'] = true;
        } else {
            $debug['general'] = false;
        }
        if (isset($_POST['adrotate_debug_dashboard'])) {
            $debug['dashboard'] = true;
        } else {
            $debug['dashboard'] = false;
        }
        if (isset($_POST['adrotate_debug_userroles'])) {
            $debug['userroles'] = true;
        } else {
            $debug['userroles'] = false;
        }
        if (isset($_POST['adrotate_debug_userstats'])) {
            $debug['userstats'] = true;
        } else {
            $debug['userstats'] = false;
        }
        if (isset($_POST['adrotate_debug_stats'])) {
            $debug['stats'] = true;
        } else {
            $debug['stats'] = false;
        }
        if (isset($_POST['adrotate_debug_timers'])) {
            $debug['timers'] = true;
        } else {
            $debug['timers'] = false;
        }
        if (isset($_POST['adrotate_debug_track'])) {
            $debug['track'] = true;
        } else {
            $debug['track'] = false;
        }
        update_option('adrotate_debug', $debug);
        // Return to dashboard
        adrotate_return('settings_saved');
    } else {
        adrotate_nonce_error();
        exit;
    }
}