Esempio n. 1
0
function adrotate_options()
{
    global $wpdb, $wp_roles;
    $active_tab = isset($_GET['tab']) ? esc_attr($_GET['tab']) : 'general';
    $status = isset($_GET['status']) ? esc_attr($_GET['status']) : '';
    $error = isset($_GET['error']) ? esc_attr($_GET['error']) : '';
    ?>

	<div class="wrap">
	  	<h1><?php 
    _e('AdRotate Settings', 'adrotate-pro');
    ?>
</h1>

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

		<h2 class="nav-tab-wrapper">  
            <a href="?page=adrotate-settings&tab=general" class="nav-tab <?php 
    echo $active_tab == 'general' ? 'nav-tab-active' : '';
    ?>
">General</a>  
            <a href="?page=adrotate-settings&tab=notifications" class="nav-tab <?php 
    echo $active_tab == 'notifications' ? 'nav-tab-active' : '';
    ?>
">Notifications</a>  
            <a href="?page=adrotate-settings&tab=stats" class="nav-tab <?php 
    echo $active_tab == 'stats' ? 'nav-tab-active' : '';
    ?>
">Stats</a>  
            <a href="?page=adrotate-settings&tab=geo" class="nav-tab <?php 
    echo $active_tab == 'geo' ? 'nav-tab-active' : '';
    ?>
">Geo Targeting</a>  
            <a href="?page=adrotate-settings&tab=advertisers" class="nav-tab <?php 
    echo $active_tab == 'advertisers' ? 'nav-tab-active' : '';
    ?>
">Advertisers</a>  
            <a href="?page=adrotate-settings&tab=roles" class="nav-tab <?php 
    echo $active_tab == 'roles' ? 'nav-tab-active' : '';
    ?>
">Roles</a>  
            <a href="?page=adrotate-settings&tab=misc" class="nav-tab <?php 
    echo $active_tab == 'misc' ? 'nav-tab-active' : '';
    ?>
">Misc</a>  
            <a href="?page=adrotate-settings&tab=maintenance" class="nav-tab <?php 
    echo $active_tab == 'maintenance' ? 'nav-tab-active' : '';
    ?>
">Maintenance</a>  
            <a href="?page=adrotate-settings&tab=license" class="nav-tab <?php 
    echo $active_tab == 'license' ? 'nav-tab-active' : '';
    ?>
">License</a>  
        </h2>		

	  	<form name="settings" id="post" method="post" action="admin.php?page=adrotate-settings">
	    	<input type="hidden" name="adrotate_settings_tab" value="<?php 
    echo $active_tab;
    ?>
" />

			<?php 
    wp_nonce_field('adrotate_email_test', 'adrotate_nonce');
    ?>
			<?php 
    wp_nonce_field('adrotate_settings', 'adrotate_nonce_settings');
    ?>
			<?php 
    wp_nonce_field('adrotate_license', 'adrotate_nonce_license');
    ?>

			<?php 
    $adrotate_config = get_option('adrotate_config');
    $adrotate_debug = get_option('adrotate_debug');
    if ($active_tab == 'general') {
        $adrotate_crawlers = get_option('adrotate_crawlers');
        $crawlers = '';
        if (is_array($adrotate_crawlers)) {
            $crawlers = implode(', ', $adrotate_crawlers);
        }
        include "dashboard/settings/general.php";
    } elseif ($active_tab == 'notifications') {
        $adrotate_notifications = get_option("adrotate_notifications");
        $notification_mails = $advertiser_mails = '';
        if (is_array($adrotate_notifications['notification_email_publisher'])) {
            $notification_mails = implode(', ', $adrotate_notifications['notification_email_publisher']);
        }
        if (is_array($adrotate_notifications['notification_email_advertiser'])) {
            $advertiser_mails = implode(', ', $adrotate_notifications['notification_email_advertiser']);
        }
        include "dashboard/settings/notifications.php";
    } elseif ($active_tab == 'stats') {
        include "dashboard/settings/statistics.php";
    } elseif ($active_tab == 'geo') {
        $adrotate_geo_requests = get_option("adrotate_geo_requests");
        $adrotate_geo = adrotate_get_cookie('geo');
        include "dashboard/settings/geotargeting.php";
    } elseif ($active_tab == 'advertisers') {
        include "dashboard/settings/advertisers.php";
    } elseif ($active_tab == 'roles') {
        include "dashboard/settings/roles.php";
    } elseif ($active_tab == 'misc') {
        include "dashboard/settings/misc.php";
    } elseif ($active_tab == 'maintenance') {
        $adrotate_version = get_option('adrotate_version');
        $adrotate_db_version = get_option('adrotate_db_version');
        $adrotate_advert_status = get_option("adrotate_advert_status");
        $adevaluate = wp_next_scheduled('adrotate_evaluate_ads');
        $adschedule = wp_next_scheduled('adrotate_notification');
        $adtracker = wp_next_scheduled('adrotate_clean_trackerdata');
        include "dashboard/settings/maintenance.php";
    } elseif ($active_tab == 'license') {
        $adrotate_is_networked = adrotate_is_networked();
        $adrotate_hide_license = get_option('adrotate_hide_license');
        if ($adrotate_is_networked) {
            $adrotate_activate = get_site_option('adrotate_activate');
        } else {
            $adrotate_activate = get_option('adrotate_activate');
        }
        $subscription = '';
        if ($adrotate_activate['version'] == 104) {
            $subscription = $adrotate_activate['type'] == 'Single' ? 'Lifetime ' : 'Subscription ';
        }
        include "dashboard/settings/license.php";
    }
    ?>

			<?php 
    if ($active_tab != 'license') {
        ?>
		    <p class="submit">
		      	<input type="submit" name="adrotate_options_submit" class="button-primary" value="<?php 
        _e('Update Options', 'adrotate-pro');
        ?>
" />
		    </p>
		    <?php 
    }
    ?>
		</form>
	</div>
<?php 
}
Esempio n. 2
0
</th>
		<td><label for="adrotate_geo_pass"><input name="adrotate_geo_pass" type="text" class="search-input" size="50" value="<?php 
echo $adrotate_config['geo_pass'];
?>
" autocomplete="off" /></label></td>
	</tr>
</table>

<?php 
if ($adrotate_config['enable_geo'] > 0) {
    adrotate_geolocation();
    if (isset($_SESSION['adrotate-geo'])) {
        $geo = $_SESSION['adrotate-geo'];
        $geo_source = 'Session data';
    } else {
        $geo = adrotate_get_cookie('geo');
        $geo_source = 'Cookie';
    }
    ?>
	<h3>Your Geo Targeting Data</h3>
	<p><strong>CAUTION! When you change Geo Services the cookie needs to refresh. You may have to save the settings once or twice for that to happen.</strong><br />
	If re-saving doesn't seem to help, remove the cookie manually from your browsers debug/info console.<br /><br />
	Cookie or _SESSION: <?php 
    echo $geo_source;
    ?>
<br />
	<pre><?php 
    print_r($geo);
    ?>
</pre>
	</p>
function adrotate_filter_location($selected, $banner)
{
    global $adrotate_debug;
    // Grab geo data from session or from cookie data
    if (isset($_SESSION['adrotate-geo'])) {
        $geo = $_SESSION['adrotate-geo'];
        $geo_source = 'Session data';
    } else {
        $geo = adrotate_get_cookie('geo');
        $geo_source = 'Cookie';
    }
    if (is_array($geo)) {
        $cities = unserialize(stripslashes($banner->cities));
        $countries = unserialize(stripslashes($banner->countries));
        if (!is_array($cities)) {
            $cities = array();
        }
        if (!is_array($countries)) {
            $countries = array();
        }
        if ($adrotate_debug['general'] == true or $adrotate_debug['geo'] == true) {
            echo "<p><strong>[DEBUG][adrotate_filter_location] Ad (id: " . $banner->id . ")</strong><pre>";
            echo "Cookie or _SESSION: " . $geo_source;
            echo "<br />Geo Provider: " . $geo['provider'] . " (Code: " . $geo['status'] . ")";
            echo "<br />Visitor City and State: " . $geo['city'] . " (DMA: " . $geo['dma'] . "), " . $geo['state'] . " (ISO: " . $geo['statecode'] . ")";
            echo "<br />Advert Cities/States (" . count($cities) . "): ";
            print_r($cities);
            echo "<br />Visitor Country: " . $geo['country'] . " (" . $geo['countrycode'] . ")";
            echo "<br />Advert Countries (" . count($countries) . "): ";
            print_r($countries);
            echo "</pre></p>";
        }
        if ($geo['status'] == 200) {
            if (count($cities) > 0 and count(array_intersect($cities, array($geo['city'], $geo['dma'], $geo['state'], $geo['statecode']))) == 0) {
                unset($selected[$banner->id]);
                return $selected;
            }
            if (count($countries) > 0 and !in_array($geo['countrycode'], $countries)) {
                unset($selected[$banner->id]);
                return $selected;
            }
        }
    } else {
        if ($adrotate_debug['general'] == true or $adrotate_debug['geo'] == true) {
            echo "<p><strong>[DEBUG][adrotate_filter_location] Ad (id: " . $banner->id . ")</strong><pre>";
            print_r($geo);
            echo "</pre></p>";
        }
    }
    return $selected;
}