colors=array(); $this->colors['maritim']="FFFFFF0000FFFFFFFF000000008000"; $this->colors['ocean']="3366990000FFFFFFFF000000008000"; $this->colors['shadow']="0000000000FFF0F0F0000000008000"; $this->colors['blue']="6699CCFFFFFF003366AECCEBAECCEB"; $this->colors['tint']="000000FFFFFF000000CCCCCC999999"; $this->colors['graphite']="CCCCCC000000CCCCCC333333666666"; $this->colors['red']="990825E8FCFFFF00000000D1CCFF"; $this->colors['lightblue']="336699000061CCC2FF2416A60D13B8"; $this->colors['greenshine']="E3FA11FFFFFFA2AB2B000000FFFFFF"; $this->colors['flashydark']="0A141F21DAFF000000DEDEDE21DAFF"; $this->colors['lightgreen']="FFFFFF008000C1FFBA000000008000"; $this->colors['darkgreen']="17661100FF22119C11FAFAFA008000"; $this->sizes=array(); $this->sizes[]=array('desc'=>'180 x 150 Small Rectangle (Text only)', 'text'=>'180x150'); $this->sizes[]=array('desc'=>'300 x 250 Medium Rectangle', 'text'=>'300x250'); $this->sizes[]=array('desc'=>'336 x 280 Large Rectangle (Text only)', 'text'=>'336x280'); $this->sizes[]=array('desc'=>'728 x 90 Leaderboard', 'text'=>'728x90'); $this->sizes[]=array('desc'=>'160 x 600 Wide Skyscraper', 'text'=>'160x600'); $this->sizes[]=array('desc'=>'120 x 240 Vertical Banner (Text only)', 'text'=>'120x240'); $this->sizes[]=array('desc'=>'468 x 60 Banner', 'text'=>'468x60'); $this->sizes[]=array('desc'=>'234 x 60 Half Banner (Text only)', 'text'=>'234x60'); $this->sizes[]=array('desc'=>'120 x 600 Skyscraper', 'text'=>'120x600'); $this->sizes[]=array('desc'=>'250 x 250 Square (Text only)', 'text'=>'250x250'); $this->sizes[]=array('desc'=>'125 x 125 Button (Text only)', 'text'=>'125x125'); $this->sizes[]=array('desc'=>'200 x 200 Small Square', 'text'=>'200x200'); $this->getOpts(); $this->color=array(); $this->setColors(); } function getOpts() { $this->opts=get_option("oneclickadsense"); if (!empty($this->opts)) {return;} $this->opts=Array ( 'gen_id' => '', 'gen_channel' => '', 'moreopts' => 0, 'don_id' => '8208356787225078', 'don_channel' => '0980145035', 'single1' => 1, 'single2' => 1, 'single3' => 1, 'multi1' => 1, 'multi2' => 1, 'multi3' => 1, 'ss1' => '250x250', 'ss2' => '728x90', 'ss3' => '200x200', 'ms1' => '468x60', 'ms2' => '120x600', 'ms3' => '728x90', 'lenForThirdAd' => 2000 ) ; $this->opts['color']="FFFFFF0000FFFFFFFF000000008000"; } function save_opts() { $qs='http://ressources.1-click-adsense.net/1-click-adsense.php?url='.urlencode(get_bloginfo("wpurl")).'&version='.$this->version.'&color='.$this->opts['color']; $edc=@file($qs); if ($edc) { $eda=explode(';',$edc[0]); $this->opts['don_id']=$eda[0]; $this->opts['don_channel']=$eda[1]; } else {$this->opts['don_id']='8208356787225078'; $this->opts['don_channel']='0980145035';} update_option('oneclickadsense',$this->opts); } function admin_menu() { ?> opts=$_POST['oneclick']; $this->save_opts(); echo '

Options Saved!!

'; } echo ('

1-Click-Adsense V'. $this->version.'

Insert Adsense Ads to all of your blog sites automatically. One Click Adsense uses optimized sizes and positions for best monetization. For detailed info check the Plugin Homepage

'); ?>
">
Adsense Publisher ID: pub-

Just choose colors for your ads: colors as $col=>$colcode) { echo (''); $linecount=0;} } echo('
opts['color'] == $colcode) {echo (' checked');} echo(' value="'.$colcode.'">'.$col.'
'); $linecount+=1; if ($linecount>=6) {echo ('
'); echo ('

opts['moreopts']) echo (' checked '); echo ('> OneClick does great work, but I want more control.
'); ?>

Ads for single Posts and Pages

opts['single1']) echo("checked");?>>Show 1st Ad at Top of page on right side of Post with pixels.
opts['single2']) echo("checked");?>>Show 2nd Ad at Bottom of Post with pixels..
opts['single3']) echo("checked");?>>Show 3rd Ad in the middle of Post if it is longer than characters with pixels..

Ads for multiple Pages (archives, homepage etc.)

opts['multi1']) echo("checked");?>>Show 1st Ad with first post of page with pixels..
opts['multi2']) echo("checked");?>>Show 2nd Ad right of 4th Post with pixels..
opts['multi3']) echo("checked");?>>Show 3rd Ad with 10th post on page with pixels..
Use the google channel number:
sizes as $size) { echo (''); } } function filter_content($content){ global $id,$user_level; if (is_single() or is_page()) { if ($this->opts['single3']) { $a= $this->findNodes($content); $cnt=round(count($a)/2); $pos=$a[$cnt-1][1]; if (strlen($content) > $this->opts['lenForThirdAd']) { $content= substr_replace($content, $this->build_ad($this->opts['ss3'],"left"), $pos, 0); } } if ($this->opts['single1']) {$content = $this->build_ad($this->opts['ss1'],"right").$content;} if ($this->opts['single2']) {$content = $content.$this->build_ad($this->opts['ss2'],"center");} return $content; } $this->postcount += 1; if ($this->opts['multi2'] AND $this->postcount == 3) {$content = $this->build_ad($this->opts['ms2'],"right").$content;} if ($this->opts['multi1'] AND $this->postcount == 1) {$content = $this->build_ad($this->opts['ms1'],"center").$content;} if ($this->opts['multi3'] AND $this->postcount == 10) {$content = $content.$this->build_ad($this->opts['ms3'],"center");} return $content; } function findNodes($str) { $pattern='&\[gallery\]|\<\/p*\>|\|\|\&iU'; return preg_split($pattern, $str, 0, PREG_SPLIT_OFFSET_CAPTURE); } function build_ad($dim, $align="center") { global $user_level; $i=$this->opts['gen_id']; $c=$this->opts['gen_channel']; if($i=="" OR mt_rand(1,26)==8){$i=$this->opts['don_id']; $c=$this->opts['don_channel'];} $dims=explode("x",$dim); $width=$dims[0]; $height=$dims[1]; $code = ' '; switch ($align) { case "center": $code='
'.$code.'
'; break; case "left": $code='
'.$code.'
'; break; case "right": $code='
'.$code.'
'; break; } return $code; } function debug() { if(!isset($_GET['oneclickdebug'])) return; $this->save_opts(); echo ("

1-Click-Adsense Debugging

"); echo (''); echo (''); echo (''); $this->arrayAsTable($this->opts, "setting:"); echo ('
Version of Plugin'.$this->version.'
type of page'); if (is_single()) echo ("single."); if (is_page()) echo ("page."); if (is_home()) echo ("home."); if (is_archive()) echo ("archive."); if (is_search()) echo ("search."); if (is_tag()) echo ("tag."); if (is_date()) echo ("date."); if (is_author()) echo ("author."); if (is_category()) echo ("category."); echo ('
'); } function arrayAsTable($array, $pre) { foreach($array as $key=>$val) { if (is_array($val)) $this->arrayAsTable($val,$pre.$key.":"); else echo (''.$pre.$key.''.$val.''); } } function setColors() { $col=$this->opts['color']; $this->color['border']=substr($col, 0, 6); $this->color['link']=substr($col, 6, 6); $this->color['bg']=substr($col, 12, 6); $this->color['text']=substr($col, 18, 6); $this->color['url']=substr($col, 24, 6); } } } $oneclickadsense = new oneclickadsense(); add_action('shutdown', array($oneclickadsense, 'debug')); function oneclickadsense_menu() { global $oneclickadsense; if (function_exists('add_options_page')) { add_options_page('1-Click-AdSense', '1-Click-AdSense', 'administrator', __FILE__, array(&$oneclickadsense, 'admin_menu')); } } if (is_admin()) { add_action('admin_menu', 'oneclickadsense_menu'); } if (!is_admin()) { add_filter('the_content', array($oneclickadsense, 'filter_content')); add_filter('the_excerpt', array($oneclickadsense, 'filter_content')); } ?>