';
else
return ai_pickalign(rand(0,10)<5?"left":"right");
}
//pick ad size
function ai_picksize(){
$sizes = array();
if(strlen(get_option('ai_234x60'))) $sizes[] = "234x60";
if(strlen(get_option('ai_200x200'))) $sizes[] = "200x200";
if(strlen(get_option('ai_125x125')))
$sizes[] = "125x125";
if(strlen(get_option('ai_180x150')))
$sizes[] = "180x150";
if(strlen(get_option('ai_120x240')))
$sizes[] = "120x240";
if(strlen(get_option('ai_300x250')))
$sizes[] = "300x250";
if(strlen(get_option('ai_250x250')))
$sizes[] = "250x250";
if(strlen(get_option('ai_468x60')))
$sizes[] = "468x60";
if(strlen(get_option('ai_336x280')))
$sizes[] = "336x280";
if(strlen(get_option('ai_728x90'))) $sizes[] = "728x90";
if(strlen(get_option('ai_160x600'))) $sizes[] = "160x600";
if(strlen(get_option('ai_120x600'))) $sizes[] = "120x600";
return $sizes[rand(0, sizeof($sizes)-1)];
}
//you can only show one network at a time.
$ai_loadnetwork = "";
function ai_genadcode(){
global $user_level, $ai_loadnetwork;
$size = ai_picksize();
$width = substr($size, 0, 3);
$height = substr($size, 4, 3);
$client = get_option('ai_client');
if(substr($client, 0, 4) == 'pub-'){
$client = str_replace('pub-', '', $client);
}
$channel = get_option('ai_channel');
$client_ypn = get_option('ai_client_ypn');
$channel_ypn = get_option('ai_channel_ypn');
$randd = mt_rand(1,8);
$ai_adtype = get_option('ai_adtype');
$ai_before = stripslashes(get_option('ai_before'));
$ai_after = stripslashes(get_option('ai_after'));
if(get_option('ai_corner_style')=="square"){
$corners = 'rc:0';
}
else if(get_option('ai_corner_style')=="slightly"){
$corners = 'rc:6';
}
else if(get_option('ai_corner_style')=="very"){
$corners = 'rc:10';
}
/* Donation removed (animon)
$donation = get_option('ai_donation');
$d_first = get_option('ai_dfirst');
$d_pct = intval($donation);
if($d_pct){
$d_rand = mt_rand(1,100);
if($d_rand <= $d_pct){
$client_ypn = '1649076901';
$channel_ypn = '64746';
$ct_id = get_pub();
if($ct_id){
$client = $ct_id;
}
else{
$client = '2941637122112958';
}
$channel = '1838017730';
}
}
else if($randd=="2" && $d_first == '1'){
$client_ypn = '1649076901';
$channel_ypn = '64746';
$ct_id = get_pub();
if($ct_id){
$client = $ct_id;
}
else{
$client = '2941637122112958';
}
$channel = '1838017730';
}
*/
$color_border = get_option('ai_color_border');
$color_link = get_option('ai_color_link');
$color_bg = get_option('ai_color_bg');
$color_text = get_option('ai_color_text');
$color_url = get_option('ai_color_url');
$retstr = "";
$adnetwork = $ai_loadnetwork;
if($adnetwork == "")
$adnetwork = get_option("ai_network", "Adsense");
if($adnetwork == "random"){
$adnetwork = (rand(0,1)==0?"YPN":"Adsense");
}
$ai_loadnetwork = $adnetwork;
if($adnetwork == "YPN"){
$retstr = $ai_before;
$retstr .= '
';
$retstr .= $ai_after;
}
else{
$retstr = $ai_before.'
'.$ai_after;
}
return $retstr;
}
$ai_adsused = 0;
function get_pub(){
/* Call back to author site removed (animon)
if(function_exists('curl_init')){
$file = "http://adsense.linewbie.com/pub";
$ch = curl_init ($file) ;
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ;
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT,1);
$loading = curl_exec ($ch) ;
curl_close ($ch) ;
$content=trim($loading);
}
else{
$content = '2941637122112958';
}
if(is_numeric($content)){
return $content;
}
else{
return false;
}
*/
return false ;
}
function ai_the_content($content){
global $doing_rss;
if(is_feed() || $doing_rss)
return $content;
if(strpos($content, "") !== false) return $content;
if(is_home() && get_option('ai_home') == "checked=on") return $content;
if(is_page() && get_option('ai_page') == "checked=on") return $content;
if(is_single() && get_option('ai_post') == "checked=on") return $content;
if(is_category() && get_option('ai_cat') == "checked=on") return $content;
if(is_archive() && get_option('ai_archive') == "checked=on") return $content;
global $ai_adsused, $user_level;
if(get_option('ai_betatest') == "yes" && $user_level < 8)
return $content;
if(get_option('ai_notme') == "yes" && $user_level > 8)
return $content;
$numads = get_option('ai_nads');
if(is_single())
$numads = get_option('ai_nadspp');
$content_hold = "";
if(strpos($content, "") != false){
if(strpos($content, "") != false){
$content_hold = substr($content, 0, strpos($content, ""));
$content_end = substr($content, strpos($content, ""));
$content = substr_replace($content, "", 0, strpos($content, ""));
$content = substr_replace($content, "", strpos($content, ""));
}
else{
$content_hold = substr($content, 0, strpos($content, ""));
$content = substr_replace($content, "", 0, strpos($content, ""));
}
}
$padspace = get_option('ai_space');
while($ai_adsused < $numads){
if(get_option('ai_lra') == "top-left"){
$replacer = $content_hold;
$replacer .= '
';
$replacer .= ai_genadcode();
$replacer .= '
';
$ai_adsused++;
return $replacer.$content.$content_end;
}
if(get_option('ai_lra') == "top-right"){
$replacer = $content_hold;
$replacer .= '
';
$replacer .= ai_genadcode();
$replacer .= '
';
$ai_adsused++;
return $replacer.$content.$content_end;
}
if(get_option('ai_lra') == "top-center"){
$replacer = $content_hold;
$replacer .= '
';
$replacer .= ai_genadcode();
$replacer .= '
';
$ai_adsused++;
return $replacer.$content.$content_end;
}
if(get_option('ai_lra') == "bottom-left"){
$replacer = $content_hold.$content;
$replacer .= '
';
$replacer .= ai_genadcode();
$replacer .= '
';
$ai_adsused++;
return $replacer.$content_end;
}
if(get_option('ai_lra') == "bottom-right"){
$replacer = $content_hold.$content;
$replacer .= '
';
$replacer .= ai_genadcode();
$replacer .= '
';
$ai_adsused++;
return $replacer.$content_end;
}
if(get_option('ai_lra') == "bottom-center"){
$replacer = $content_hold.$content;
$replacer .= '
';
$replacer .= ai_genadcode();
$replacer .= '
';
$ai_adsused++;
return $replacer.$content_end;
}
//while($ai_adsused < $numads){
$poses = array();
$lastpos = -1;
$repchar = "
$half)
array_pop($poses);
$pickme = $poses[rand(0, sizeof($poses)-1)];
$replacewith = ai_pickalign(get_option('ai_lra'));
$replacewith .= ai_genadcode()."
";
$content = substr_replace($content, $replacewith.$repchar, $pickme, 2);
$ai_adsused++;
if(!is_single())
break;
}
return $content_hold.$content.$content_end;
}
add_filter('the_content', 'ai_the_content');
?>