function adinj_install_db()
{
    $new_options = adinj_default_options();
    // Dynamic defaults.
    if (!is_supported_caching_plugin_active()) {
        $new_options['ad_insertion_mode'] = 'direct';
    }
    adinj_update_options($new_options);
    if (adinj_mfunc_mode()) {
        // Create config file.
        adinj_write_config_file();
    }
}
Example #2
0
function adinj_insertion_mode_box($ops)
{
    adinj_postbox_start(__("Ad insertion mode and dynamic ad display restrictions", 'adinj'), 'restrictions');
    ?>
	<h4>Ad insertion mode</h4>
	<blockquote>
	<input type="radio" name="ad_insertion_mode" value="direct" <?php 
    if (adinj_direct_mode()) {
        echo 'checked="checked"';
    }
    ?>
 /> <b>direct: Direct ad code insertion <font color="green">(recommended)</font></b> - Adds are directly inserted into the page. Note that dynamic features (the ones in this section) will not work if you are using a caching plugin as dynamic features require that the page is dynamically generated each time a user views it.<br />
	
	<input type="radio" name="ad_insertion_mode" value="mfunc" <?php 
    if (adinj_mfunc_mode()) {
        echo 'checked="checked"';
    }
    ?>
 /> <b>mfunc: Insert ads using cache compatible mfunc tags <font color="red">(not recommended)</font></b> - unless you are 100% certain you understand mfunc mode and know what you are doing!<br />
	
	<?php 
    if (!adinj_mfunc_mode()) {
        ?>
	<script type="text/javascript">
	document.write('<style type="text/css" media="screen">#caching_plugin_msg { display: none; }</style>');
	</script>
	<?php 
    }
    ?>
	<br />
	
	<div id="caching_plugin_msg" class="caching_plugin_msg">
	Dynamic features may work with older versions of WP Super Cache, W3 Total Cache and WP Cache. Only select this mode if you are using an older version of one of those caching plugins that you know supports mfunc and want to use dynamic features (IP / referrer restriction, alt content and ad roatation). If you aren't using dynamic features or don't understand what mfunc is then select direct mode. This mode is left in for people who know exactly what mfunc mode is and understand the risks of using it. If you have to ask then use direct mode.
	<?php 
    if (!is_supported_caching_plugin_active()) {
        echo '<p><b><span style="font-size:10px;color:red;">Note: A supported caching plugin does not appear to be active. If you are not using WP Super Cache / W3 Total Cache / WP Cache you should use one of the direct insertion modes below.</span></b></p>';
    }
    ?>
	<?php 
    if (is_plugin_active('wp-super-cache/wp-cache.php')) {
        adinj_wp_super_cache_msg();
    } else {
        if (is_plugin_active('w3-total-cache/w3-total-cache.php')) {
            adinj_w3_total_cache_msg();
        } else {
            if (is_plugin_active('wp-cache/wp-cache.php')) {
                adinj_wp_cache_msg();
            }
        }
    }
    adinj_unknown_cache_msg();
    ?>
	</div>
	
	<br />
	
	
	</blockquote>

	<p></p>
	
	<script type="text/javascript">
	jQuery(document).ready(function(){
	jQuery('input[name=ad_insertion_mode]:radio').change(function() {
		if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct"){
			jQuery('.caching_plugin_msg').slideUp(300);
		} else { // mfunc
			jQuery('.caching_plugin_msg').slideDown(300);
		}
		return true;
		});
	});
	</script>
	
	
	<h4><a name="dynamic"></a>Show ads only to visitors from these search engines or websites (dynamic feature)</h4>
	
	<blockquote>
	<?php 
    adinj_add_checkbox('sevisitors_only');
    _e("Only show ads to visitors from these websites (customise search engine or website referrers below). When a user visits from one of these referrers they will see ads <b>for the next hour</b> (sets a 1 hour cookie).", 'adinj');
    ?>
<br />
	<textarea name="ad_referrers" rows="2" cols="<?php 
    adinj_table_width('dynamic');
    ?>
"><?php 
    echo $ops['ad_referrers'];
    ?>
</textarea>
	<p>Comma separated list e.g.: <br /><code>.google., .bing., .yahoo., .ask., search?, search., facebook.com, t.co</code></p>
	</blockquote>

	
	<h4>Blocked referrer keywords (dynamic feature)</h4>
	
	<blockquote>
	<?php 
    adinj_add_checkbox('block_keywords');
    _e("Don't show ads to visitors from external sites if the referrer contains one of these keywords or substrings.", 'adinj');
    ?>
 If a blocked string is found block ads for: <?php 
    adinj_selection_box("block_ads_for_hours", array('1' => '1 hour', '2' => '2 hours', '3' => '3 hours', '6' => '6 hours', '24' => '1 day', '48' => '2 days', '72' => '3 days', '168' => '1 week', '720' => '30 days', '8760' => '1 year'));
    ?>
<br />
	<textarea name="blocked_keywords" rows="2" cols="<?php 
    adinj_table_width('dynamic');
    ?>
"><?php 
    echo $ops['blocked_keywords'];
    ?>
</textarea>
	<p>Comma separated list e.g.: <br /><code>facebook.com, .org, james+bond</code></p>
	</blockquote>

	
	<h4>Blocked IP addresses (dynamic feature)</h4>
	
	<blockquote>
	<?php 
    adinj_add_checkbox('block_ips');
    _e("Exclude ads from these IP addresses.", 'adinj');
    ?>
<br />
	<textarea name="blocked_ips" rows="4" cols="<?php 
    adinj_table_width('dynamic');
    ?>
"><?php 
    echo $ops['blocked_ips'];
    ?>
</textarea>
	<p>Comma separated list e.g.: <br /><code>0.0.0.1, 0.0.0.2</code></p>
	<p>Or you can list one IP per line with optional comments e.g.</p>
	<code style="padding:0px 0px">192.168.0.1<br />0.0.0.2<br /><?php 
    echo $_SERVER['REMOTE_ADDR'];
    ?>
 //my ip<br />0.0.0.3</code>
	
	<p>For reference your current IP address is <code><?php 
    echo $_SERVER['REMOTE_ADDR'];
    ?>
</code></p>
	</blockquote>

	
	
	
	<?php 
    adinj_postbox_end();
}