Adsense" menu.
Version: 1.70
Author: linewbie
Author URI: http://www.linewbie.com/wordpress-plugins/
*/
/*
Copyright (C) 2007 Linewbie.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
';
if($dump){var_dump($str);}else{print_r($str);}
echo '';
}
//dump(get_defined_functions());
function ai_add_options(){
if(function_exists('add_options_page')){
add_options_page('Adsense', 'Adsense', 9, basename(__FILE__), 'ai_options_subpanel');
}
}
//validate options
switch($_POST['action']){
case 'Save':
update_option('ai_network', $_POST['ai_network']);
if(isset($_POST['betatest'])) update_option('ai_betatest', "yes");
else delete_option('ai_betatest');
if(isset($_POST['notme'])) update_option('ai_notme', "yes");
else delete_option('ai_notme');
if(isset($_POST['googtestmode'])) update_option('ai_googtestmode', "yes");
else delete_option('ai_googtestmode');
if(isset($_POST['dontshowinstr'])) update_option('ai_dontshowinstr', "yes");
if(isset($_POST['showinstr'])) update_option('ai_dontshowinstr', "no");
update_option('ai_adtype', $_POST['ai_adtype']);
update_option('ai_before', $_POST['ai_before']);
update_option('ai_after', $_POST['ai_after']);
update_option('ai_color_border', $_POST['ai_color_border']);
update_option('ai_color_link', $_POST['ai_color_link']);
update_option('ai_color_bg', $_POST['ai_color_bg']);
update_option('ai_color_text', $_POST['ai_color_text']);
update_option('ai_color_url', $_POST['ai_color_url']);
update_option('ai_corner_style', $_POST['corner_style']);
update_option('ai_lra', $_POST['ai_pos']);
update_option('ai_space', $_POST['ai_space']);
update_option('ai_nads', $_POST['nads']);
update_option('ai_shownum', $_POST['shownum']);
//shownum
update_option('ai_nadspp', $_POST['nadspp']);
update_option('ai_text_only', false);
update_option('ai_client', $_POST['ai_client']);
update_option('ai_channel', $_POST['ai_channel']);
update_option('ai_client_ypn', $_POST['ai_client_ypn']);
update_option('ai_channel_ypn', $_POST['ai_channel_ypn']);
if(isset($_POST['donation']) && $_POST['donation'] != ''){
update_option('ai_donation', $_POST['donation']);
update_option('ai_dfirst', 0);
}
else{
update_option('ai_dfirst', 1);
}
if($_POST['234x60'] == "on") update_option('ai_234x60', "checked=on");
else update_option('ai_234x60', "");
if($_POST['200x200'] == "on") update_option('ai_200x200', "checked=on");
else update_option('ai_200x200', "");
if($_POST['125x125'] == "on") update_option('ai_125x125', "checked=on");
else update_option('ai_125x125', "");
if($_POST['180x150'] == "on") update_option('ai_180x150', "checked=on");
else update_option('ai_180x150', "");
if($_POST['120x240'] == "on") update_option('ai_120x240', "checked=on");
else update_option('ai_120x240', "");
if($_POST['300x250'] == "on") update_option('ai_300x250', "checked=on");
else update_option('ai_300x250', "");
if($_POST['250x250'] == "on") update_option('ai_250x250', "checked=on");
else update_option('ai_250x250', "");
if($_POST['336x280'] == "on") update_option('ai_336x280', "checked=on");
else update_option('ai_336x280', "");
if($_POST['468x60'] == "on") update_option('ai_468x60', "checked=on");
else update_option('ai_468x60', "");
if($_POST['home'] == "on") update_option('ai_home', "checked=on");
else update_option('ai_home', "");
if($_POST['page'] == "on") update_option('ai_page', "checked=on");
else update_option('ai_page', "");
if($_POST['post'] == "on") update_option('ai_post', "checked=on");
else update_option('ai_post', "");
if($_POST['cat'] == "on") update_option('ai_cat', "checked=on");
else update_option('ai_cat', "");
if($_POST['archive'] == "on") update_option('ai_archive', "checked=on");
else update_option('ai_archive', "");
break;
}
//user enter required data here
function ai_options_subpanel(){
if(get_option("ai_network", "") == "") {
update_option("ai_network", "Adsense");
update_option("ai_adtype", "text");
update_option("ai_corner_style", "square");
}
$ad_client = get_option('ai_client');
$ad_channel = get_option('ai_channel');
$ad_client_ypn = get_option('ai_client_ypn');
$ad_channel_ypn = get_option('ai_channel_ypn');
$adnetwork = get_option("ai_network", "Adsense");
$ai_adtype = get_option('ai_adtype');
$ai_corner_style = get_option('ai_corner_style');
$ai_before = get_option('ai_before');
$ai_after = get_option('ai_after');
$ai_space = get_option('ai_space');
$lra = get_option('ai_lra');
$nads = get_option('ai_nads');
$shownum = get_option('ai_shownum');
//shownum
$nadspp = get_option('ai_nadspp');
$text_only = get_option('ai_text_only');
$ai_color_border = get_option('ai_color_border');
$ai_color_link = get_option('ai_color_link');
$ai_color_bg = get_option('ai_color_bg');
$ai_color_text = get_option('ai_color_text');
$ai_color_url = get_option('ai_color_url');
$ai_donation = get_option('ai_donation');
?>
',' ')?' ':' ';//if appearthe use the space instead it
$exp = explode($char,$ct2begain);
/*insert the ads into the two args if exist data then change it to array and insert into those ads in it and
* then merge those
*/
$adscontent = $befor.$adscontent.$end;
$arry = implode($char,array_insert($exp,mt_rand(0,count($exp)-1),array($adscontent)));
$ct2end = $ed[1];//the data after the args
return $b.''.$ct2begain.$ai_before.$arry.$ai_after.''.$ct2end;
break;
case 'shuffer'://display the ads by random
$ads = ' ')?' ';
$e = explode($char,$content);
return implode($char,array_insert($e,mt_rand(0,count($e)-1),array($ai_before.$adscontent.$ai_after)));
break;
case 'top'://display ads on top
$ads = ' ',' $half)
array_pop($poses);
$pickme = $poses[rand(0, sizeof($poses)-1)];
$replacewith = $befor.$ai_before.$adscontent.$ai_after.$end;//拿一个DIV把已显示的广告包起来
return substr_replace($content, $replacewith.$repchar, $pickme, 2);*/
break;
default://return the random mode the old version in fact may be not use it i forgot
$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_before.'
',' ','','&',' ','>','”',';');
$char = $char[array_rand($char)];
$char = !strpos($content,$char)?' ':$char;
$et = explode($char,$content);
return implode($char,array_insert($et,rand(0,count($et)),array($str)));
}
/**
* explode the content core
*
* @param string $flag
* @param string $content
* @param int $adsnumber
* @param string $class css style class
* @return string
*/
function explodeCt($flag,$content,$adsnumber,$class,$out=false,$mainclass=''){
$padspace = get_option('ai_space');//
$position = get_option('ai_lra');
$ai_before = '';
$ai_after = '';
$WH = getAdsWH();
$w = $WH['width'];// ads 宽度
//$h = $WH['height'];//ads 高度
//$adstyles = ' width:'.$w.'px; height:'.$h.'px;';
//$m_w = $w*$adsnumber+$adsnumber*$padspace+20;//获得总宽度
//$m_h = $h+$adsnumber*$padspace+20;
//$adstyles = $adsnumber=1?'width:'.$w.'px;':'width:80%;'.'px;';
$adstyles = '';
$m_w = $w*$adsnumber+20;//获得总宽度
$style = 'width:'.$m_w.'px;margin:0px auto;';
$befor = $out?'
':'
',' ','','&',' ','>','”');
$char = $char[array_rand($char)];
$char = !strpos($content,$char)?' ':$char;
$et = explode($char,$content);
return implode($char,array_insert($et,rand(0,count($et)),array($befor.$adscontent.$end)));
/*$poses = array();
$lastpos = -1;
$repchar = "