AdSense Manager - Version 2.6

Version Description

Download this release

Release Info

Developer mutube
Plugin Icon wp plugin AdSense Manager
Version 2.6
Comparing to
See all releases

Code changes from version 2.5 to 2.6

adsense-manager.css ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* Can change this */
3
+ #adsensem_dbx fieldset {
4
+ margin-bottom: 1em;
5
+ }
6
+
7
+ #adsensem_dbx h3 {
8
+ padding: 3px;
9
+ font-weight: normal;
10
+ font-size: 13px;
11
+ }
12
+
13
+ #adsensem_dbx div {
14
+ margin-top: .5em;
15
+ }
16
+
17
+ #adsensem_dbx h3.dbx-handle {
18
+ margin-left: 7px;
19
+ margin-bottom: -7px;
20
+ padding: 6px 1em 0 3px;
21
+ height: 19px;
22
+ font-size: 12px;
23
+ background: #2685af url(../../../../wp-admin/images/box-head-right.gif) no-repeat top right;
24
+ }
25
+
26
+ #adsensem_dbx div.dbx-handle-wrapper {
27
+ margin: 0 0 0 -7px;
28
+ background: #fff url(../../../../wp-admin/images/box-head-left.gif) no-repeat top left;
29
+ }
30
+
31
+ #adsensem_dbx div.dbx-content {
32
+ margin-left: 8px;
33
+ background: url(../../../../wp-admin/images/box-bg-right.gif) repeat-y right;
34
+ padding: 10px 10px 15px 0;
35
+ }
36
+
37
+ #adsensem_dbx div.dbx-content-wrapper {
38
+ margin-left: -7px;
39
+ margin-right: 0;
40
+ background: url(../../../../wp-admin/images/box-bg-left.gif) repeat-y left;
41
+ }
42
+
43
+ #adsensem_dbx fieldset.dbx-box {
44
+ padding-bottom: 9px;
45
+ margin-left: 6px;
46
+ background: url(../../../../wp-admin/images/box-butt-right.gif) no-repeat bottom right;
47
+ }
48
+
49
+ #adsensem_dbx div.dbx-box-wrapper {
50
+ background: url(../../../../wp-admin/images/box-butt-left.gif) no-repeat bottom left;
51
+ }
52
+
53
+ #adsensem_dbx .dbx-box-closed div.dbx-content-wrapper {
54
+ padding-bottom: 2px;
55
+ background: url(../../../../wp-admin/images/box-butt-left.gif) no-repeat bottom left;
56
+ }
57
+
58
+ #adsensem_dbx .dbx-box {
59
+ background: url(../../../../wp-admin/images/box-butt-right.gif) no-repeat bottom right;
60
+ }
61
+
62
+ #adsensem_dbx a.dbx-toggle, #adsensem_dbx a.dbx-toggle-open:visited {
63
+ height: 22px;
64
+ width: 22px;
65
+ top: 3px;
66
+ right: 5px;
67
+ background-position: 0 -3px;
68
+ }
69
+
70
+ #adsensem_dbx a.dbx-toggle-open, #adsensem_dbx a.dbx-toggle-open:visited {
71
+ height: 22px;
72
+ width: 22px;
73
+ top: 3px;
74
+ right: 5px;
75
+ background-position: 0 -28px;
76
+ }
77
+
78
+ #adsensem_dbx .adsensem_label{
79
+ text-align:right;
80
+ width:10em;
81
+ }
82
+
83
+ th {border-bottom:2px solid #000;font-size:smaller;}
84
+ #default-options td{border-bottom:1px solid #000;}
85
+ #manage-ads {}
86
+ #manage-ads td, #manage-ads th {padding: 1px 5px;}
87
+
88
+ .network_blanking {height:20px;}
89
+ .network_header td {border-top:1px solid #000;font-weight:bold;background-color:#ddd;}
90
+ .network_admin * {font-weight:normal; text-align:center;}
91
+ .adrow td { border-bottom:1px dotted #888 }
92
+ .adrow_name { padding-left:25px;}
93
+
94
+ .disabled { background-color:#e5e5e5;}
95
+
96
+ .shade_0 {background-color:#eee;}
97
+ .shade_1 {background-color:#f5f5f5;}
98
+
99
+ #adsensem_dbx { width:100%; }
100
+ #adsensem_dbx .formlayoutsection { vertical-align:top; width:33% }
101
+
102
+ .network_header a {border-bottom:none;text-decoration:underline;}
103
+
104
+ .Ad_AdBrite {padding-left: 25px; background: transparent url(http://files.adbrite.com/mb/images/favicon.ico) no-repeat center left; }
105
+ .Ad_AdRoll {padding-left:25px;background:url(http://www.adroll.com/i/favicon.ico) left no-repeat;}
106
+ .Ad_AdSense {padding-left:25px;background:url(http://www.google.com/favicon.ico) left no-repeat;}
107
+ .Ad_AdSense_Classic {padding-left:25px;background:url(http://www.google.com/favicon.ico) left no-repeat;}
108
+ .Ad_CJ {padding-left:25px;background:url(http://www.cj.com/favicon.ico) left no-repeat;}
109
+ .Ad_Code {padding-left:25px;background:url(./code.png) left no-repeat;}
110
+ .Ad_WidgetBucks {padding-left:25px;background:url(http://www.widgetbucks.com/favicon.ico) left no-repeat;}
111
+ .Ad_ShoppingAds {padding-left:25px;background:url(./shoppingads.png) left no-repeat;}
112
+ .Ad_Adpinion {padding-left:25px;background:url(http://www.adpinion.com/static/images/logo_small.gif) left no-repeat;}
adsense-manager.js ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ function adsensem_form_update(element){
4
+ //element is the calling element, element.id has the identifier
5
+ //detect calling form element and action accordingly
6
+ switch(element.id){
7
+ /* case 'adsensem-product':adsensem_update_product(); break; */
8
+ case 'adsensem-adformat':adsensem_update_custom(); break;
9
+ case 'adsensem-adtype':adsensem_update_formats(); break;
10
+ }
11
+ }
12
+
13
+
14
+ function adsensem_update_color(element,id,what){
15
+ target=document.getElementById(id);
16
+ switch(what) {
17
+ case 'bg': target.style.background='#' + element.value; break;
18
+ case 'title': target.style.color='#' + element.value; break;
19
+ case 'text': target.style.color='#' + element.value; break;
20
+ case 'border': target.style.border='1px solid #' + element.value; break;
21
+ case 'link': target.style.color='#' + element.value; break;
22
+ }
23
+ }
24
+
25
+ function adsensem_update_formats(){
26
+
27
+ list=new Array('adformat','linkformat','referralformat');
28
+
29
+ if(document.getElementById('adsensem-adtype')){
30
+ switch(document.getElementById('adsensem-adtype').value){
31
+ case 'ad': keep='adformat'; break;
32
+ case 'link': keep='linkformat'; break;
33
+ case 'ref_image': keep='referralformat'; break;
34
+ case 'ref_text': keep=false; break;
35
+ }
36
+
37
+ for(a=0;a<list.length;a++){
38
+ if(list[a]!=keep){ document.getElementById('adsensem-form-'+list[a]).style.display='none'; }
39
+ else { document.getElementById('adsensem-form-'+list[a]).style.display=''; }
40
+ }
41
+
42
+ }
43
+ }
44
+
45
+
46
+ function adsensem_update_custom(){
47
+
48
+ if(document.getElementById('adsensem-adformat') && document.getElementById('adsensem-settings-custom')){
49
+ format=document.getElementById('adsensem-adformat').value;
50
+
51
+ if(format=='custom'){on='';} else {on='none';}
52
+ document.getElementById('adsensem-settings-custom').style.display=on
53
+ }
54
+ }
55
+
56
+
57
+ //Initialize everything (call the display/hide functions)
58
+
59
+
60
+ addLoadEvent(function(){ adsensem_update_custom()});
61
+ addLoadEvent(function(){ adsensem_update_formats()});
62
+
63
+
64
+ //End Initialise
65
+
66
+
67
+
68
+
69
+ addLoadEvent( function() {var manager = new dbxManager( 'adsensem_dbx' );} );
70
+ addLoadEvent( function()
71
+ {
72
+ var adsensem_dbx1 = new dbxGroup(
73
+ 'adsensem_dbx1', // container ID [/-_a-zA-Z0-9/]
74
+ 'vertical', // orientation ['vertical'|'horizontal']
75
+ '7', // drag threshold ['n' pixels]
76
+ 'no', // restrict drag movement to container axis ['yes'|'no']
77
+ '10', // animate re-ordering ['n' frames per transition]
78
+ 'yes', // include open/close toggle buttons ['yes'|'no']
79
+ 'open', // default state ['open'|'closed']
80
+
81
+ 'open', // word for "open", as in "open this box"
82
+ 'close', // word for "close", as in "close this box"
83
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
84
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
85
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
86
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
87
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
88
+ );
89
+ var adsensem_dbx2 = new dbxGroup(
90
+ 'adsensem_dbx2', // container ID [/-_a-zA-Z0-9/]
91
+ 'vertical', // orientation ['vertical'|'horizontal']
92
+ '7', // drag threshold ['n' pixels]
93
+ 'no', // restrict drag movement to container axis ['yes'|'no']
94
+ '10', // animate re-ordering ['n' frames per transition]
95
+ 'yes', // include open/close toggle buttons ['yes'|'no']
96
+ 'open', // default state ['open'|'closed']
97
+
98
+ 'open', // word for "open", as in "open this box"
99
+ 'close', // word for "close", as in "close this box"
100
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
101
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
102
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
103
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
104
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
105
+ );
106
+ var adsensem_dbx3 = new dbxGroup(
107
+ 'adsensem_dbx3', // container ID [/-_a-zA-Z0-9/]
108
+ 'vertical', // orientation ['vertical'|'horizontal']
109
+ '7', // drag threshold ['n' pixels]
110
+ 'no', // restrict drag movement to container axis ['yes'|'no']
111
+ '10', // animate re-ordering ['n' frames per transition]
112
+ 'yes', // include open/close toggle buttons ['yes'|'no']
113
+ 'open', // default state ['open'|'closed']
114
+
115
+ 'open', // word for "open", as in "open this box"
116
+ 'close', // word for "close", as in "close this box"
117
+ 'click-down and drag to move this box', // sentence for "move this box" by mouse
118
+ 'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
119
+ 'use the arrow keys to move this box', // sentence for "move this box" by keyboard
120
+ ', or press the enter key to %toggle% it', // pattern-match sentence-fragment for "(open|close) this box" by keyboard
121
+ '%mytitle% [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
122
+ );
123
+
124
+ }
125
+ );
adsense-manager.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: AdSense Manager
4
  PLugin URI: http://wordpress.org/extend/plugins/adsense-manager/
5
  Description: Control and arrange your AdSense & Referral blocks on your Wordpress blog. With Widget and inline post support, configurable colours.
6
  Author: Martin Fitzpatrick
7
- Version: 2.5
8
  Author URI: http://www.mutube.com/
9
  */
10
 
@@ -17,7 +17,7 @@ Defaults
17
 
18
  */
19
 
20
- @define("ADSENSEM_VERSION", "2.5");
21
  @define('ADSENSEM_DIRPATH','/wp-content/plugins' . strrchr(dirname(__FILE__),'/') . "/");
22
 
23
  /*
@@ -25,13 +25,10 @@ Defaults
25
  */
26
 
27
  //Currently not used
28
- @define("ADSENSEM_MAX_ADS", 7); //Max Google Ad units
29
- @define("ADSENSEM_MAX_REFERRALS", 7); //Max Google Referral units
30
 
31
  @define("ADSENSEM_BE_NICE", 3); //Default level only, can be changed in Options/AdSense Manager
32
- //Network Code: http://am.mutube.com/ad/200x5
33
- //NYUD Code: http://am.mutube.com.nyud.net:8080/ad/200x5
34
- @define("ADSENSEM_BE_NICE_BASEURL", 'http://am.mutube.com/ad/'); //Location for Be Nice ads
35
 
36
 
37
  /* Copyright 2006 MARTIN FITZPATRICK (email : martin.fitzpatrick@gmail.com)
@@ -51,6 +48,30 @@ Defaults
51
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
52
  */
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  /*
56
 
@@ -62,25 +83,18 @@ Defaults
62
  */
63
 
64
  //Kept external for backward compatibility
65
- if(!function_exists('adsensem_status')) {
66
-
67
- function adsensem_ad($name=false) {
68
-
69
- global $adsensem;
70
-
71
- $options = get_option('plugin_adsensem');
72
- if($name===false)
73
- {$ad=$options['ads'][$options['defaults']['ad']];}
74
- else
75
- {$ad=$options['ads'][$name];}
76
-
77
- echo $adsensem->get_ad($ad,$name);
78
- }
79
-
80
  }
81
 
82
 
83
-
84
  /*
85
 
86
  INITIALISATION
@@ -89,1200 +103,173 @@ function adsensem_ad($name=false) {
89
  */
90
 
91
  class adsensem {
92
-
93
- function get_ad_inline($ad=false,$name /* passthru */) {
94
-
95
- $options = get_option('plugin_adsensem');
96
-
97
- if($ad===false){$ad=$options['ads'][$options['defaults']['ad']];}
98
- $ad=$this->merge_defaults($ad); //Apply defaults
99
-
100
- $code='';
101
- /* This test block determines whether to display the Ad in the current location.
102
- The home,single,archive,search tests only apply to Ads displayed inline,
103
- so we test for that here */
104
- if( (($ad['show-home']=='yes') && is_home()) ||
105
- (($ad['show-post']=='yes') && (is_single() || is_page())) ||
106
- (($ad['show-archive']=='yes') && is_archive()) ||
107
- (($ad['show-search']=='yes') && is_search()) )
108
- { /* We passed the test, display the Ad */
109
- $code.=$this->get_ad($ad,$name);
110
- }
111
- return $code;
112
- }
113
-
114
- function get_ad($ad=false,$name='') {
115
- global $ADSENSEM_PUBLISHER;
116
-
117
- $options = get_option('plugin_adsensem');
118
-
119
- if($ad===false){$ad=$options['ads'][$options['defaults']['ad']];}
120
- $ad=$this->merge_defaults($ad); //Apply defaults
121
-
122
- $code='';
123
-
124
- /* Valid entry */
125
- if(is_array($ad)){
126
-
127
- //Default to Ad
128
- if($ad['product']=='link'){
129
- $format = $ad['linkformat'] . $ad['linktype'];
130
- list($width,$height,$null)=split('[x]',$ad['linkformat']);
131
- } else if($ad['product']=='referral-image') {
132
- $format = $ad['referralformat'] . '_as_rimg';
133
- list($width,$height,$null)=split('[x]',$ad['referralformat']);
134
- } else if($ad['product']=='referral-text') {
135
- $format = 'ref_text';
136
- } else {
137
- $format = $ad['adformat'] . '_as';
138
- list($width,$height,$null)=split('[x]',$ad['adformat']);
139
-
140
- //BENICE: Only display image/banner ads to avoid Google requirement for text ads to look different
141
- if( ($ad['adtype'] == 'text_image') || ($ad['adtype'] == 'image') ) {
142
-
143
- if(rand(1,100)<=$options['be-nice']){
144
- //$benicead = $this->be_nice_url($ad);
145
- $ad['product']='code'; //Override the actual ad format
146
- $ad['code'] = $this->be_nice_code($ad); //'<iframe frameborder="0" scrolling="no" src="' . $benicead . '" width="' . $width . '" height="' . $height . '"></iframe>';
147
- } else if( ($ad['alternate-url']=="") && ($ad['alternate-color']=="") && ($options['be-nice']!=0) ){
148
- //Output Be Nice Alternate Ad url? Only if none has been specified & it's valid place to do it. Sorted.
149
- $ad['alternate-url'] = $this->be_nice_url($ad);
150
- }
151
-
152
- }
153
- }
154
-
155
- $code .= $ad['html-before'];
156
-
157
- if($_GET['preview']){
158
-
159
- /* We are in the editor, output fake */
160
- if($ad['product']=='code'){
161
- //Complicated to extract dimensions from code, for now just output "default" sized object.
162
- $code .= '<div style="text-align:center;border:1px solid #000;font-size:25px;width:250px;height:100px">';
163
- $code .= 'AdSense Code Unit<br />#' . $name;
164
- $code .= '</div>';
165
- } else if($ad['product']=='referral-text'){
166
- //Text link referral
167
- $code .= '<span style="text-decoration:underline;color:#00f">AdSense Referral Link #' . $name . '</span>';
168
- } else {
169
- /* We are in the editor, output fake */
170
-
171
- /* Thanks to silverblood for the font-size bugfix: http://wordpress.org/support/topic/130523 */
172
- $font_size = (round($width/4,0) < round($height/4,0) )? round($width/4,0) : round($height/4,0);
173
- $code .= '<div style="text-align:center;border:1px solid #000;font-size:' . $font_size . 'px;width:' . $width . 'px;height:' . $height . 'px">';
174
- $code .= 'AdSense ' . ucwords(str_replace("-"," ",$ad['product'])) . '<br />#' . $name;
175
- $code .= '</div>';
176
- }
177
-
178
- } else {
179
-
180
- if($ad['product']=='code'){
181
- $code.=$ad['code'];
182
- } else {
183
-
184
- $code .= '<script type="text/javascript"><!--' . "\n";
185
- $code.= 'google_ad_client = "pub-' . $options['adsense-account'] . '";' . "\n";
186
-
187
- if($ad['channel']!==''){ $code.= 'google_ad_channel = "' . $ad['channel'] . '";' . "\n"; }
188
-
189
- if(($ad['product']=='ad') || ($ad['product']=='link') || ($ad['product']=='referral-image')){
190
- $code.= 'google_ad_width = ' . $width . ";\n";
191
- $code.= 'google_ad_height = ' . $height . ";\n";
192
- }
193
-
194
- $code.= 'google_ad_format = "' . $format . '"' . ";\n";
195
-
196
- if($ad['alternate-url']!=''){ $code.= 'google_alternate_ad_url = "' . $ad['alternate-url'] . '";' . "\n";}
197
- else if($ad['alternate-color']!=''){ $code.= 'google_alternate_color = "' . $ad['alternate-color'] . '";' . "\n";}
198
-
199
- //Default to Ads
200
- if($ad['product']=='ad'){ $code.= 'google_ad_type = "' . $ad['adtype'] . '"' . ";\n"; }
201
-
202
- if($ad['product']=='referral-text'){$code.='google_ad_output = "textlink"' . ";\n";}
203
- if(($ad['product']=='referral-text') || ($ad['product']=='referral-image')){$code.='google_cpa_choice = "' . $ad['referral'] . '"' . ";\n";}
204
-
205
- if(($ad['product']=='ad') || ($ad['product']=='link')){
206
- $code.= 'google_color_border = "' . $ad['colors']['border'] . '"' . ";\n";
207
- $code.= 'google_color_bg = "' . $ad['colors']['bg'] . '"' . ";\n";
208
- $code.= 'google_color_link = "' . $ad['colors']['link'] . '"' . ";\n";
209
- $code.= 'google_color_text = "' . $ad['colors']['text'] . '"' . ";\n";
210
- $code.= 'google_color_url = "' . $ad['colors']['url'] . '"' . ";\n";
211
- }
212
-
213
- $code.= "\n" . '//--></script>' . "\n";
214
-
215
- $code.= '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>' . "\n";
216
-
217
- }
218
-
219
- }
220
-
221
- $code.=$ad['html-after'];
222
-
223
- }
224
-
225
-
226
- return $code;
227
- }
228
-
229
- /* ADMIN ELEMENTS - REUSABLE PAGE ELEMENTS FOR CONFIGURATION */
230
-
231
- function set_defaults($options,$wipebasic=false) {
232
-
233
- $options['defaults'] = array (
234
- 'colors' => array(
235
- 'border'=> 'FFFFFF',
236
- 'link' => '0000FF',
237
- 'bg' => 'FFFFFF',
238
- 'text' => '000000',
239
- 'url' => '008000'
240
- ),
241
- 'channel' => '',
242
-
243
- 'adformat' => '250x250',
244
- 'adtype' => 'text_image',
245
-
246
- 'linkformat' => '120x90',
247
- 'linktype' => '_0ads_al_s',
248
-
249
- 'show-home' => "yes",
250
- 'show-post' => "yes",
251
- 'show-archive' => "yes",
252
- 'show-search' => "yes",
253
-
254
- 'html-before' => '',
255
- 'html-after' => '',
256
-
257
- 'alternate-url' => '',
258
- 'alternate-color' => ''
259
-
260
- );
261
-
262
- if($wipebasic===true){
263
- $options['ads'] = array(
264
- 'demo-advert' => array()
265
- );
266
- $options['adsense-account']="";
267
-
268
- /* Rate is the % rate (below is the default) at which donation is made */
269
- $options['be-nice']= ADSENSEM_BE_NICE;
270
-
271
- $options['defaults']['ad'] = 'demo-advert';
272
- }
273
-
274
- return $options;
275
- }
276
-
277
- //Set up the alternate ad if it's ok to do it for this type of unit
278
- function be_nice_url($ad){
279
- $options = get_option('plugin_adsensem');
280
- $url = ADSENSEM_BE_NICE_BASEURL . $ad['adformat']; //this url will load up a network ad in the right format
281
- return $url;
282
- }
283
-
284
- function be_nice_code($ad){
285
- $adcodes = array(
286
- '728x90' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/3AXX4RVIJBCHRJTPUJHXAJ/',
287
- '468x60' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/IPCY22UCBBFBVL6HIN6X2D/',
288
- '234x60' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/H5I4KYMJE5AZFABWUYC3O3/',
289
- '120x600' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/YR67VMQYNZCUHEUPVTUTNQ/',
290
- '160x600' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/ZIQDD3H3VFA7VHXCUGEE25/',
291
- '120x240' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/F5LF4IJ5PNBJNP5534J27B/',
292
- '336x280' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/CDY6KUEZTJGO7G75A2DXJK/',
293
- '300x250' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/OMIHBI7XUBAOXLS2DRAQ4G/',
294
- '250x250' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/BOMAKAPVURD2JILCSXQ22K/',
295
- '200x200' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/P7643ZUKQ5BYDLNG6TKLMX/', //180x150 duplicated
296
- '180x150' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/P7643ZUKQ5BYDLNG6TKLMX/',
297
- '125x125' => 'http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/7L73RCFU5VCG7FRNNIGH7O/'
298
- );
299
-
300
- return '<script type="text/javascript" src="' . $adcodes[$ad['adformat']] . '"></script>';
301
-
302
- }
303
-
304
-
305
-
306
- /* MERGE DEFAULTS - Merge in default settings to fill gaps in Ad setup */
307
- function merge_defaults($settings) {
308
-
309
- $options = get_option('plugin_adsensem');
310
-
311
- if(is_array($options['defaults'])){
312
- foreach($options['defaults'] as $key=>$value) {
313
- if($settings[$key]==''){$settings[$key]=$value;}
314
- }
315
- }
316
-
317
- if(is_array($options['defaults']['colors'])){
318
- foreach($options['defaults']['colors'] as $key=>$value){
319
- if($settings['colors'][$key]==''){$settings['colors'][$key]=$value;}
320
- }
321
- }
322
 
323
- return $settings;
324
-
325
- }
326
-
327
- function output_select($list,$selected)
328
- {
329
- foreach($list as $key=>$value)
330
- {
331
- ?><option <?php if($key==$selected){ echo "selected"; }?> value="<?php echo $key; ?>"> <?php echo $value; ?></option><?php
332
- }
333
- }
334
-
335
- /* ADMIN Settings - Editing form for each Ad and defaults, reusable */
336
- function admin_settingsform($settings=array('colors'=>array()),$name=false)
337
- {
338
-
339
- $colors = $settings['colors'];
340
 
341
- if($settings['product']==''){$settings['product']='ad';}
342
-
343
- //Google AdSense data
344
 
345
- $formats['default']=array('' => 'Use Default');
346
-
347
- $formats['ads']['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner', '234x60' => '234 x 60 Half Banner');
348
- $formats['ads']['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper', '120x240' => '120 x 240 Vertical Banner');
349
- $formats['ads']['square']=array('336x280' => '336 x 280 Large Rectangle', '300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square', '200x200' => '200 x 200 Small Square', '180x150' => '180 x 150 Small Rectangle', '125x125' => '125 x 125 Button');
350
-
351
- $adtypes=array('text_image' => 'Text &amp; Image', 'image' => 'Image Only', 'text' => 'Text Only');
352
-
353
- $formats['links']['horizontal']=array('728x15' => '728 x 15', '468x15' => '468 x 15');
354
- $formats['links']['square']=array('200x90' => '200 x 90', '180x90' => '180 x 90', '160x90' => '160 x 90', '120x90' => '120 x 90');
355
-
356
- $linktypes=array('_0ads_al' => '4 Ads Per Unit', '_0ads_al_s' => '5 Ads Per Unit');
357
-
358
- $formats['referrals']['horizontal']=array('110x32' => '110 x 32', '120x60' => '120 x 60', '180x60' => '180 x 60', '468x60' => '468 x 60');
359
- $formats['referrals']['square']=array('125x125' => '125 x 125');
360
- $formats['referrals']['vertical']=array('120x240' => '120 x 240');
361
-
362
- $yesno=array("yes" => 'Yes', "no" => 'No');
363
- $default=array('' => 'Use Default');
364
-
365
- $products=array('ad' => 'Ad Unit','link' => 'Link Unit','referral-text' => "Referral (Text)",'referral-image' => "Referral (Image)");
366
- $productsextra=array('code' => 'Direct Code Ad');
367
- ?>
368
-
369
 
370
- <script type="text/javascript">
 
 
371
 
372
- function adsensem_set_color(element,id,what){
373
- target=document.getElementById(id);
374
- switch(what) {
375
- case 'bg': target.style.background='#' + element.value; break;
376
- case 'color': target.style.color='#' + element.value; break;
377
- case 'border': target.style.border='1px solid #' + element.value; break;
378
- }
379
  }
380
-
381
- function adsensem_product_options(product){
382
-
383
- all=Array('ad','link','color','referral','referral-format','code','alternate');
384
 
385
- switch (product){
386
- case 'link': show = Array('link','color','alternate');
387
- break;
388
- case 'ad': show = Array('ad','color','alternate');
389
- break;
390
- case 'referral-text':show = Array('referral');
391
- break;
392
- case 'referral-image':show = Array('referral','referral-format');
393
- break;
394
- case 'code': show = Array('code');
395
- break;
396
  }
397
-
398
- for(a=0;a<all.length;a++){
399
- found=false;
400
- for(s=0;s<show.length;s++){if(show[s]==all[a]){found=true;}}
401
- if(found){document.getElementById('adsensem-settings-' + all[a]).style.display=''}
402
- else {document.getElementById('adsensem-settings-' + all[a]).style.display='none'}
403
- }
404
-
405
- }
406
-
407
- </script>
408
-
409
- <table style="width:100%;">
410
- <tr valign="top"><td class="wrap">
411
-
412
- <h4>Basic</h4>
413
- <table>
414
- <?php if($name!==false){ ?>
415
- <tr><td><label for="adsensem-name">Name:</label></td>
416
- <td><input style="border:2px solid #000" name="adsensem-name" size="15" value="<?php echo htmlspecialchars($name, ENT_QUOTES); ?>" />
417
- <input name="adsensem-name-old" type="hidden" value="<?php echo htmlspecialchars($name, ENT_QUOTES); ?>" />
418
- </td></tr>
419
- <?php } ?>
420
- <tr><td><label for="adsensem-channel">Channel:</label></td>
421
- <td><input name="adsensem-channel" size="15" title="Enter multiple Channels seperated by + signs" value="<?php echo htmlspecialchars($settings['channel'], ENT_QUOTES); ?>" /></td></tr>
422
-
423
- <?php if($name!==false){ ?>
424
- <tr><td><label for="adsensem-product">Product:</label></td>
425
- <td><select name="adsensem-product" onchange="adsensem_product_options(this.value);">
426
- <optgroup label="Google">
427
- <?php $this->output_select($products,$settings['product']);?>
428
- </optgroup>
429
- <optgroup label="Extra">
430
- <?php $this->output_select($productsextra,$settings['product']);?>
431
- </optgroup>
432
- </select></tr>
433
- <?php } ?>
434
- </table>
435
-
436
- <div id="adsensem-settings-ad">
437
- <h4>Ad Unit Settings</h4>
438
- <table style="padding-bottom:1em;">
439
- <tr id="row-adformat"><td><label for="adsensem-adformat"><a href="https://www.google.com/adsense/adformats" target="_new">Format:</a></label></td>
440
- <td>
441
- <select name="adsensem-adformat">
442
- <!-- Options taken from Google AdSense setup pages -->
443
- <?php if($name!==false){ ?><optgroup label="Default"><?php $this->output_select($formats['default'],$settings['adformat']);?></optgroup><?php } ?>
444
- <optgroup label="Horizontal"><?php $this->output_select($formats['ads']['horizontal'],$settings['adformat']);?></optgroup>
445
- <optgroup label="Vertical"><?php $this->output_select($formats['ads']['vertical'],$settings['adformat']);?></optgroup>
446
- <optgroup label="Square"><?php $this->output_select($formats['ads']['square'],$settings['adformat']);?></optgroup>
447
- </select>
448
- </td></tr>
449
-
450
- <tr id="row-adtype"><td><label for="adsensem-adtype">Ad Type:</label></td>
451
- <td>
452
- <select name="adsensem-adtype">
453
- <!-- Options taken from Google AdSense setup pages -->
454
- <?php if($name!==false){ ?><?php $this->output_select($default,$settings['adtype']);?><?php } ?>
455
- <?php $this->output_select($adtypes,$settings['adtype']);?>
456
- </select>
457
- </td></tr>
458
- </table>
459
- </div>
460
-
461
- <div id="adsensem-settings-link">
462
- <h4>Link Unit Settings</h4>
463
- <table style="padding-bottom:1em;">
464
- <tr id="row-linkformat"><td><label for="adsensem-linkformat"><a href="https://www.google.com/adsense/adformats" target="_new">Format:</a></label></td>
465
- <td>
466
- <select name="adsensem-linkformat">
467
- <!-- Options taken from Google AdSense setup pages -->
468
- <?php if($name!==false){ ?><optgroup label="Default"><?php $this->output_select($formats['default'],$settings['adformat']);?></optgroup><?php } ?>
469
- <optgroup label="Horizontal"><?php $this->output_select($formats['links']['horizontal'],$settings['adformat']);?></optgroup>
470
- <optgroup label="Square"><?php $this->output_select($formats['links']['square'],$settings['adformat']);?></optgroup>
471
- </select>
472
- </td></tr>
473
-
474
- <tr id="row-linktype"><td><label for="adsensem-linktype">Link Type:</label></td>
475
- <td>
476
- <select name="adsensem-linktype">
477
- <!-- Options taken from Google AdSense setup pages -->
478
- <?php if($name!==false){ ?><?php $this->output_select($default,$settings['linktype']);?><?php } ?>
479
- <?php $this->output_select($linktypes,$settings['linktype']);?>
480
- </select>
481
- </td></tr>
482
- </table>
483
- </div>
484
-
485
- <?php //Referral units & code have no "defaults" so cannot be set up in this way
486
- if($name!==false){ ?>
487
-
488
- <div id="adsensem-settings-referral">
489
- <h4>Referral Settings</h4>
490
- <table style="padding-bottom:1em;">
491
- <tr id="adsensem-settings-referral-format"><td style="width:7em;"><label for="adsensem-referralformat"><a href="https://www.google.com/adsense/adformats" target="_new">Format:</a></label></td>
492
- <td>
493
- <select name="adsensem-referralformat" id="adsensem-referralformat">
494
- <!-- Options taken from Google AdSense setup pages -->
495
- <optgroup label="Horizontal"><?php $this->output_select($formats['referrals']['horizontal'],$settings['referralformat']);?></optgroup>
496
- <optgroup label="Square"><?php $this->output_select($formats['referrals']['square'],$settings['referralformat']);?></optgroup>
497
- <optgroup label="Vertical"><?php $this->output_select($formats['referrals']['vertical'],$settings['referralformat']);?></optgroup>
498
- </select>
499
- </td></tr>
500
-
501
- <tr><td><label for="adsensem-referral">Referral Code:</label></td>
502
- <td><input name="adsensem-referral" size="25" title="Enter referral code from Google AdSense site" value="<?php echo htmlspecialchars($settings['referral'], ENT_QUOTES); ?>" /> (CPA)</td></tr>
503
- </table>
504
- </div>
505
-
506
- <div id="adsensem-settings-code">
507
- <h4>Code Settings</h4>
508
- <table id="adsensem-settings-code" style="padding-bottom:1em;">
509
-
510
- <tr id="row-code"><td style="width:7em;"><label for="adsensem-code"><a href="https://www.google.com/adsense/adsense-products" target="_new">Ad Unit Code:</a></label></td>
511
- <td>
512
- <textarea rows="5" cols="30" name="adsensem-code"><?php echo htmlspecialchars($settings['code'], ENT_QUOTES); ?></textarea>
513
- </td></tr>
514
-
515
- <tr id="row-code-convert"><td></td><td><input type="checkbox" name="adsensem-code-convert" value="1"> <label for="adsensem-codeconvert">convert to AdSense Manager unit [<a href="#" title="Convert AdSense code into an editable AdSense Manager unit.">?</a>]</label></td></tr>
516
- </table>
517
- </div><?php } ?>
518
-
519
- </td><td class="wrap" id="adsensem-settings-color">
520
-
521
- <h4>Ad Colours</h4>
522
- <table>
523
- <tr><td><label for="adsensem-colors-border">Border:</label></td>
524
- <td>#<input name="adsensem-colors-border" onChange="adsensem_set_color(this,'ad-color-border','border');" size="6" value="<?php echo htmlspecialchars($colors['border'], ENT_QUOTES); ?>" /></td></tr>
525
- <tr><td><label for="adsensem-colors-link">Title:</label></td>
526
- <td>#<input name="adsensem-colors-link" onChange="adsensem_set_color(this,'ad-color-link','color');" size="6" value="<?php echo htmlspecialchars($colors['link'], ENT_QUOTES); ?>" /></td></tr>
527
- <tr><td><label for="adsensem-colors-bg">Background:</label></td>
528
- <td>#<input name="adsensem-colors-bg" onChange="adsensem_set_color(this,'ad-color-bg','bg');" size="6" value="<?php echo htmlspecialchars($colors['bg'], ENT_QUOTES); ?>" /></td></tr>
529
- <tr><td><label for="adsensem-colors-text">Text:</label></td>
530
- <td>#<input name="adsensem-colors-text" onChange="adsensem_set_color(this,'ad-color-text','color');" size="6" value="<?php echo htmlspecialchars($colors['text'], ENT_QUOTES); ?>" /></td></tr>
531
- <tr><td><label for="adsensem-colors-url">URL:</label></td>
532
- <td>#<input name="adsensem-colors-url" onChange="adsensem_set_color(this,'ad-color-url','color');" size="6" value="<?php echo htmlspecialchars($colors['url'], ENT_QUOTES); ?>" /></td></tr>
533
- <tr><td colspan="2">
534
-
535
- <?php
536
-
537
- //Add in default settings for display
538
- if($name!==false){
539
- $temp=$this->merge_defaults($settings);
540
- $colors = $temp['colors'];
541
- } else {
542
- $colors = $settings['colors'];
543
- }
544
-
545
- ?>
546
- <div id="ad-color-bg" style="margin-top:1em;width:160px;background: #<?php echo htmlspecialchars($colors['bg'], ENT_QUOTES); ?>;">
547
- <div id="ad-color-border" style="font: 10px arial, sans-serif; border: 1px solid #<?php echo htmlspecialchars($colors['border'], ENT_QUOTES); ?>" class="linkunit-wrapper">
548
- <div id="ad-color-link" style="color: #<?php echo htmlspecialchars($colors['link'], ENT_QUOTES); ?>; font: 11px verdana, arial, sans-serif; padding: 2px;">
549
- <b><u>Linked Title</u></b><br /></div>
550
- <div id="ad-color-text" style="color: #<?php echo htmlspecialchars($colors['text'], ENT_QUOTES); ?>; padding: 2px;" class="text">
551
- Advertiser's ad text here<br /></div>
552
- <div id="ad-color-url" style="color: #<?php echo htmlspecialchars($colors['url'], ENT_QUOTES); ?>; font: 10px verdana, arial, sans-serif; padding: 2px;">
553
- www.advertiser-url.com<br /></div>
554
- <div style="color: #000; padding: 2px;" class="rtl-safe-align-right">
555
- &nbsp;<u>Ads by Google</u></div>
556
- </div>
557
- </div>
558
- </td></tr>
559
- </table>
560
-
561
- </td><td class="adsensemcol wrap">
562
-
563
- <h4>Show Inline Ads</h4>
564
-
565
- <table>
566
- <tr><td><label for="adsensem-show-home">On Homepage</label></td>
567
- <td><select name="adsensem-show-home">
568
-
569
- <?php if($name!==false){ ?><?php $this->output_select($default,$settings['show-home']);?><?php } ?>
570
- <?php $this->output_select($yesno,$settings['show-home']);?>
571
- </select></td></tr>
572
- <tr><td><label for="adsensem-show-post">On Posts/Pages</label></td>
573
- <td><select name="adsensem-show-post">
574
- <?php if($name!==false){ ?><?php $this->output_select($default,$settings['show-post']);?><?php } ?>
575
- <?php $this->output_select($yesno,$settings['show-post']);?>
576
- </select></td></tr>
577
- <tr><td><label for="adsensem-show-archive">On Archives</label></td>
578
- <td><select name="adsensem-show-archive">
579
- <?php if($name!==false){ ?><?php $this->output_select($default,$settings['show-archive']);?><?php } ?>
580
- <?php $this->output_select($yesno,$settings['show-archive']);?>
581
- </select></td></tr>
582
- <tr><td><label for="adsensem-show-search">On Search</label></td>
583
- <td><select name="adsensem-show-search">
584
- <?php if($name!==false){ ?><?php $this->output_select($default,$settings['show-search']);?><?php } ?>
585
- <?php $this->output_select($yesno,$settings['show-search']);?>
586
- </select></td></tr>
587
- </table>
588
-
589
-
590
- <h4>HTML Markup (Optional)</h4>
591
- <table>
592
- <tr><td><label for="adsensem-html-before">Before:</label></td>
593
- <td><input name="adsensem-html-before" size="15" title="Enter HTML to be included before Ad unit" value="<?php echo htmlspecialchars($settings['html-before'], ENT_QUOTES); ?>" /></td></tr>
594
- <tr><td><label for="adsensem-html-after">After:</label></td>
595
- <td><input name="adsensem-html-after" size="15" title="Enter HTML to be included after Ad unit" value="<?php echo htmlspecialchars($settings['html-after'], ENT_QUOTES); ?>" /></td></tr>
596
- </table>
597
-
598
- <div id="adsensem-settings-alternate">
599
- <h4>Alternate Ads (Optional)</h4>
600
- <table>
601
- <tr><td><label for="adsensem-alternate-url">URL:</label></td>
602
- <td><input name="adsensem-alternate-url" size="20" title="Enter URL to alternate Ad for display when Google Ad unavailable" value="<?php echo htmlspecialchars($settings['alternate-url'], ENT_QUOTES); ?>" /></td></tr>
603
- <tr><td><label for="adsensem-alternate-color">Color:</label></td>
604
- <td>#<input name="adsensem-alternate-color" size="6" title="Enter #COLOUR to display when Google Ad unavailable" value="<?php echo htmlspecialchars($settings['alternate-color'], ENT_QUOTES); ?>" /></td></tr>
605
- </table>
606
- </div>
607
-
608
-
609
-
610
- </td></tr>
611
- </table>
612
- <?php if($name!==false){ ?>
613
- <script>adsensem_product_options('<?php echo $settings['product']; ?>');</script>
614
- <?php }
615
- }
616
-
617
- /*
618
- ADMIN FORM FUNCTIONS
619
-
620
- */
621
-
622
- /* Define basic settings for the AdSense Manager - for block control use admin_manage */
623
-
624
- function admin_options() {
625
-
626
- // Get our options and see if we're handling a form submission.
627
- $options = get_option('plugin_adsensem');
628
-
629
- if ( $_POST['adsensem-submit'] ) {
630
-
631
- $options['adsense-account']=preg_replace('/\D/','',$_POST['adsensem-adsense-account']);
632
-
633
- $options['be-nice']=max(min($_POST['adsensem-be-nice'],100),0);
634
- if(!is_numeric($options['be-nice'])){$options['be-nice'] = ADSENSEM_BE_NICE;}
635
-
636
- update_option('plugin_adsensem', $options);
637
-
638
- }
639
-
640
- // Here is our little form segment. Notice that we don't need a
641
- // complete form. This will be embedded into the existing form.
642
-
643
- ?>
644
- <form action="" method="post" id="adsensem-manage" enctype="multipart/form-data">
645
-
646
- <div class="wrap">
647
- <h2>AdSense Manager Options</h2>
648
-
649
- <p>Configure your basic settings here, such as default colours &amp; Google account settings.
650
- Once you have set up the basics, click <strong>Save &raquo;</strong> to save changes, then go to <a href="<?php echo get_bloginfo('wpurl');?>/wp-admin/edit.php?page=adsense-manager-manage">Manage &raquo; Ads</a> to create your Ad blocks.</p>
651
-
652
- <h3>Basic Setup</h3>
653
- <p>Enter your <label for="adsensem-adsense-account">Google AdSense <strong>Account ID</strong></label>: <input name="adsensem-adsense-account" value="<?php echo strip_tags(stripslashes($options['adsense-account'])); ?>"
654
- style="<?php if($options['adsense-account']!=''){echo "font-weight:bold; color:green; ";} else { echo "border:1px solid red;"; }?>">
655
-
656
- <br />You can find this number at the bottom of your <a href="https://www.google.com/adsense/account-settings" target="_new">Account Settings</a> page.</p>
657
- </p>
658
-
659
- <p class="submit"><input type="submit" value="Save changes &raquo;"></p>
660
- </div>
661
- <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
662
-
663
- <div id="message" class="updated">
664
- <p style="text-align:justify;">
665
- <?php if($options['be-nice'] == 0){?>Please <a href="http://www.mutube.com/about/be-nice">Be Nice</a> and donate more than
666
- <?php } else { ?> Thankyou for <a href="http://www.mutube.com/about/be-nice">Being Nice</a> and continuing to donate <?php } ?>
667
- <input style="border:none;text-align:right;<?php if($options['be-nice']==0){ echo 'color:red;'; } ?>" name="adsensem-be-nice" value="<?php echo htmlspecialchars($options['be-nice'], ENT_QUOTES);?>" size="1">% of your Ad space to support development of this plugin [<a href="http://wordpress.org/extend/plugins/adsense-manager/faq/" target="_blank">?</a>]
668
- <?php if($options['be-nice'] == 0){?> It didn't write itself.<?php } ?>
669
- </p>
670
- </div>
671
- z <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
672
-
673
- </form>
674
-
675
- <?php
676
- }
677
-
678
- function admin_adsense_code_convert() {
679
-
680
- $code=stripslashes($_POST['adsensem-code']);
681
-
682
- if(preg_match('/google_ad_channel = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-channel'] = $matches[1]; }
683
- if(preg_match('/google_alternate_ad_url = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-alternate-url'] = $matches[1]; }
684
- if(preg_match('/google_alternate_color = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-alternate-color'] = $matches[1]; }
685
-
686
- $width=false; $height=false;
687
- if(preg_match('/google_ad_width = (\d*);/', $code, $matches)!=0){ $width = $matches[1]; }
688
- if(preg_match('/google_ad_height = (\d*);/', $code, $matches)!=0){ $height = $matches[1]; }
689
- if( ($width!==false) && ($height!==false) ) { $format = $width . "x" . $height; }
690
-
691
- //as_rimg - Referral (Image)
692
- //ref_text - Referral (Text)
693
- //_0ads_al - Link Unit
694
- //_as - Ad Unit
695
-
696
- if(preg_match('/google_ad_format = "(.*)"/', $code, $matches)!=0){
697
-
698
- $adformat=$matches[1];
699
- if(strstr($adformat,'_as_rimg')!==false){
700
- preg_match('/google_cpa_choice = "(.*)"/', $code, $matches);
701
- $_POST['adsensem-referral']=$matches[1];
702
- $_POST['adsensem-product']='referral-image';
703
- $_POST['adsensem-referralformat']=$format; }
704
- else if(strstr($adformat,'ref_text')!==false){
705
- preg_match('/google_cpa_choice = "(.*)"/', $code, $matches);
706
- $_POST['adsensem-referral']=$matches[1];
707
- $_POST['adsensem-product']='referral-text';
708
- } else if(strstr($adformat,'_0adsl_al')!==false){
709
- $_POST['adsensem-product']='link';
710
- $_POST['adsensem-linkformat']=$format;
711
- if(strstr($adformat,'_0adsl_al_s')){ $_POST['linktype']="_0adsl_al_s"; } else { $_POST['linktype']="_0adsl_al"; }
712
- } else if(strstr($adformat,'_as')!==false){
713
- $_POST['adsensem-product']='ad';
714
- $_POST['adsensem-adformat']=$format;
715
  }
716
  }
717
-
718
- if(preg_match('/google_color_border = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-colors-border']=$matches[1];}
719
- if(preg_match('/google_color_bg = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-colors-link']=$matches[1];}
720
- if(preg_match('/google_color_link = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-colors-bg']=$matches[1];}
721
- if(preg_match('/google_color_text = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-colors-text']=$matches[1];}
722
- if(preg_match('/google_color_url = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-colors-url']=$matches[1];}
723
-
724
  }
725
-
726
- function admin_save_settings($ad=array()) {
727
-
728
- $ad['channel']=strip_tags(stripslashes($_POST['adsensem-channel']));
729
-
730
- $ad['product']=$_POST['adsensem-product'];
731
-
732
- $ad['adformat']=strip_tags(stripslashes($_POST['adsensem-adformat']));
733
- $ad['adtype']=strip_tags(stripslashes($_POST['adsensem-adtype']));
734
-
735
- $ad['linkformat']=strip_tags(stripslashes($_POST['adsensem-linkformat']));
736
- $ad['linktype']=strip_tags(stripslashes($_POST['adsensem-linktype']));
737
-
738
- $ad['referralformat']=strip_tags(stripslashes($_POST['adsensem-referralformat']));
739
- $ad['referral']=strip_tags(stripslashes($_POST['adsensem-referral']));
740
-
741
- $ad['code']=stripslashes($_POST['adsensem-code']);
742
-
743
- $ad['html-before']=stripslashes($_POST['adsensem-html-before']);
744
- $ad['html-after']=stripslashes($_POST['adsensem-html-after']);
745
-
746
- $ad['alternate-url']=stripslashes($_POST['adsensem-alternate-url']);
747
- $ad['alternate-color']=stripslashes($_POST['adsensem-alternate-color']);
748
-
749
- $colors['border']=strip_tags(stripslashes($_POST['adsensem-colors-border']));
750
- $colors['link']=strip_tags(stripslashes($_POST['adsensem-colors-link']));
751
- $colors['bg']=strip_tags(stripslashes($_POST['adsensem-colors-bg']));
752
- $colors['text']=strip_tags(stripslashes($_POST['adsensem-colors-text']));
753
- $colors['url']=strip_tags(stripslashes($_POST['adsensem-colors-url']));
754
-
755
- $ad['colors'] = $colors;
756
-
757
- $ad['show-home']=$_POST['adsensem-show-home'];
758
- $ad['show-post']=$_POST['adsensem-show-post'];
759
- $ad['show-archive']=$_POST['adsensem-show-archive'];
760
- $ad['show-search']=$_POST['adsensem-show-search'];
761
-
762
- return $ad;
763
-
764
- }
765
-
766
-
767
- /* Define and manage AdSense ad blocks for your Wordpress setup */
768
- function admin_manage() {
769
-
770
- // Get our options and see if we're handling a form submission.
771
- $options = get_option('plugin_adsensem');
772
-
773
- if ( $_POST['adsensem-submit'] ) {
774
-
775
- if($_POST['adsensem-edit-default']) {
776
 
777
- if($_POST['adsensem-restore-defaults']){
778
- $options = $this->set_defaults($options);
779
- } else {
780
- $options['defaults']=$this->admin_save_settings($options['defaults']);
781
- }
782
-
783
- } else {
784
-
785
- if( $_POST['adsensem-code-convert'] ){
786
- //Extract code into $_POST variables, to simulate normal submission
787
- $this->admin_adsense_code_convert();
788
- }
789
-
790
- if($_POST['adsensem-name']==''){
791
- $a=0; do { $a++; $_POST['adsensem-name']='Ad-' . $a; } while (isset($options['ads'][$_POST['adsensem-name']]));
792
- }
793
-
794
- $name=sanitize_title($_POST['adsensem-name']);
795
-
796
- /* Changing the name of an Ad, copy and delete old */
797
- if($_POST['adsensem-name']!=$_POST['adsensem-name-old']){
798
- $options['ads'][$name]=$options['ads'][$_POST['adsensem-name-old']];
799
- unset($options['ads'][$_POST['adsensem-name-old']]);
800
- /* We can now use the new $name from this point forward, lovely */
801
-
802
- /* Update default if neccessary */
803
- if($options['defaults']['ad']==$_POST['adsensem-name-old']){$options['defaults']['ad']=$name;}
804
  }
 
805
 
806
- $options['ads'][$name]=$this->admin_save_settings($options['ads'][$name]);
807
- }
808
 
809
- update_option('plugin_adsensem', $options);
810
-
811
- }
812
-
813
- if ( $_POST['adsensem-delete'] ) {
814
- //Delete selected advert
815
- if($_POST['adsensem-delete-name']!=$options['defaults']['ad']){
816
- unset($options['ads'][$_POST['adsensem-delete-name']]);
817
- update_option('plugin_adsensem', $options);
818
- }
819
- }
820
-
821
- if ( $_POST['adsensem-default'] ) {
822
- //Set selected advert as default
823
- $options['defaults']['ad']=$_POST['adsensem-default-name'];
824
- update_option('plugin_adsensem', $options);
825
- }
826
-
827
- if( ( $options['defaults']['ad']=='' ) && ( count($options['ads']>0) ) ){
828
- $options['defaults']['ad']=key($options['ads']);
829
- update_option('plugin_adsensem', $options);
830
- }
831
-
832
- if ( $_POST['adsensem-copy'] ) {
833
- //Copy selected advert
834
- $a=0; do { $a++; $copyto=$_POST['adsensem-copy-name'] . '-' . $a; } while (isset($options['ads'][$copyto]));
835
- $options['ads'][$copyto]=$options['ads'][$_POST['adsensem-copy-name']];
836
- update_option('plugin_adsensem', $options);
837
  }
838
-
839
- ?>
840
- <div class="wrap">
841
- <h2>Manage Ads</h2>
842
- <p>Below are your currently created Ads. Remember to set your <strong>Google Adsense ID</strong> at <a href="<?php echo get_bloginfo('wpurl');?>/wp-admin/options-general.php?page=adsense-manager">Options &raquo; AdSense Manager</a></p>
843
-
844
- <form action="" method="post" id="adsensem-config" enctype="multipart/form-data">
845
-
846
- <input type="hidden" name="adsensem-copy-name" id="adsensem-copy-name">
847
- <input type="hidden" name="adsensem-delete-name" id="adsensem-delete-name">
848
- <input type="hidden" name="adsensem-default-name" id="adsensem-default-name">
849
- <input type="hidden" name="adsensem-edit-name" id="adsensem-edit-name">
850
-
851
- <style type="text/css">
852
- th {border-bottom:2px solid #000;}
853
- #default-options td{border-bottom:1px solid #000;}
854
- </style>
855
-
856
- <table style="width:100%;" cellspacing="0">
857
- <tr style="height:2em;"><th>Name</th><th>Channel</th><th>Product</th><th colspan="5" style="width:80px;">Colours</th><th>Format</th><th colspan="3">Admin</th></tr>
858
-
859
- <tr style="background-color:#ddd;" id="default-options">
860
- <td style="font-weight:bold;">Default Settings</td>
861
- <td><?php echo htmlspecialchars($options['defaults']['channel'], ENT_QUOTES); ?></td>
862
- <td></td>
863
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['border'], ENT_QUOTES); ?>">&nbsp;</td>
864
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['link'], ENT_QUOTES); ?>">&nbsp;</td>
865
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['bg'], ENT_QUOTES); ?>">&nbsp;</td>
866
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['text'], ENT_QUOTES); ?>">&nbsp;</td>
867
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($options['defaults']['colors']['url'], ENT_QUOTES); ?>">&nbsp;</td>
868
- <td style="width:100px;text-align:center;"><?php echo htmlspecialchars($options['defaults']['adformat'], ENT_QUOTES); ?><br /><?php echo htmlspecialchars($options['defaults']['linkformat'], ENT_QUOTES); ?></td>
869
- <td style="width:10px;"><input name="adsensem-edit" type="submit" value="Edit" onClick="document.getElementById('adsensem-edit-name').value='';"></td>
870
- <td colspan="3"></td>
871
- </tr>
872
 
873
- <?php
874
-
875
- if(sizeof($options['ads'])!=0){
876
- foreach($options['ads'] as $name=>$ad)
877
- {
878
- ?><tr <?php if($name==$options['defaults']['ad']){?>style="background-color:#eee;"<?php } ?>>
879
- <td><?php echo htmlspecialchars($name, ENT_QUOTES); ?></td>
880
- <td><?php echo htmlspecialchars($ad['channel'], ENT_QUOTES); ?></td>
881
- <td style="text-align:center;"><?php echo htmlspecialchars(ucwords(str_replace("-"," ",$ad['product'])), ENT_QUOTES); ?></td>
882
-
883
- <?php if(($ad['product']=='ad') || ($ad['product']=='link')) { ?>
884
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['border'], ENT_QUOTES); ?>">&nbsp;</td>
885
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['link'], ENT_QUOTES); ?>">&nbsp;</td>
886
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['bg'], ENT_QUOTES); ?>">&nbsp;</td>
887
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['text'], ENT_QUOTES); ?>">&nbsp;</td>
888
- <td style="width:16px;background-color:#<?php echo htmlspecialchars($ad['colors']['url'], ENT_QUOTES); ?>">&nbsp;</td>
889
- <?php } else { ?><td colspan="5"></td><?php } ?>
890
-
891
- <td style="width:100px;text-align:center;"><?php if($ad['product']=='link'){echo htmlspecialchars($ad['linkformat'], ENT_QUOTES);} else if ($ad['product']=='ad') {echo htmlspecialchars($ad['adformat'], ENT_QUOTES);} else if ($ad['product']=='referral-image') {echo htmlspecialchars($ad['referralformat'], ENT_QUOTES);} ?></td>
892
- <td style="width:10px;"><input name="adsensem-edit" type="submit" value="Edit" onClick="document.getElementById('adsensem-edit-name').value='<?php echo $name; ?>';"></td>
893
- <td style="width:30px;"><input name="adsensem-copy" type="submit" value="+" onClick="document.getElementById('adsensem-copy-name').value='<?php echo $name; ?>';" title="Copy to new Ad unit"></td>
894
-
895
- <?php if($name!=$options['defaults']['ad']){?>
896
- <td style="width:30px"><input name="adsensem-default" type="submit" value="Set Default" onClick="document.getElementById('adsensem-default-name').value='<?php echo $name; ?>';"></td>
897
- <td style="width:30px"><input name="adsensem-delete" type="submit" value="Delete" onClick="if(confirm('Delete <?php echo $name; ?>?')){document.getElementById('adsensem-delete-name').value='<?php echo $name; ?>';} else {return false;}"></td>
898
- <?php } else { ?><td style="width:50px"><strong>Default&nbsp;Ad</strong></td><td></td><?php } ?>
899
-
900
- </tr>
901
- <?php
902
-
903
- }
904
- } else { ?><tr><td>None.</td></tr><?php }
905
- ?>
906
-
907
- </table>
908
-
909
- <p>By changing the <strong>Default settings</strong> (shown on the top line) you can update all Ads at once.
910
- <br /><strong>Default Ad</strong> indicates which Ad will be displayed when no specific ID is used. </p>
911
- <p>Ads can be included in <strong>templates</strong> using <code>&lt;?php adsensem_ad('name'); ?&gt;</code> or <code>&lt;?php adsensem_ad(); ?&gt;</code> for the default Ad.<br />
912
- Ads can be inserted into <strong>posts / pages</strong> using <code>&lt;!--adsense#name--&gt;</code> or <code>&lt;!--adsense--&gt;</code> for the default Ad.</p>
913
-
914
- <!--adsense-->
915
-
916
- </form>
917
-
918
- <br /><br />
919
-
920
- <form action="" method="post" id="adsensem-config-edit">
921
-
922
- <?php
923
-
924
- if( ($_POST['adsensem-edit']) && ($_POST['adsensem-edit-name'])=="")
925
- { $EDIT_DEFAULT = true; }
926
- else
927
- { $EDIT_DEFAULT = false; }
928
-
929
- if($_POST['adsensem-edit']){ ?>
930
-
931
- <h2>Edit '<?php echo ( $EDIT_DEFAULT )?'Default Settings':$_POST['adsensem-edit-name']; ?>'</h2>
932
- <p>Edit the settings for your Ad below. If you want to use the default settings for any element,
933
- simply leave that section unchanged.</p>
934
- <?php
935
- if( $EDIT_DEFAULT ) {
936
- $this->admin_settingsform($options['defaults'],false);
937
- } else {
938
- $this->admin_settingsform($options['ads'][$_POST['adsensem-edit-name']],$_POST['adsensem-edit-name']);
939
- }
940
-
941
- ?>
942
-
943
- <?php } else { ?>
944
- <h2>Create New</h2>
945
- <p>Enter the settings for your new Ad below. <br />If you want to use the default settings for any element,
946
- simply leave that section unchanged.</p>
947
- <?php $this->admin_settingsform(null,''); ?>
948
-
949
-
950
- <?php } ?>
951
-
952
- <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
953
- <p class="submit">
954
-
955
- <?php if( $EDIT_DEFAULT ) { ?>
956
- <input name="adsensem-restore-defaults" type="submit" value="Restore Defaults &raquo;">
957
- <input type="hidden" id="adsensem-edit-default" name="adsensem-edit-default" value="1" />
958
- <?php } ?>
959
- <input type="submit" value="Save changes &raquo;">
960
-
961
- </p>
962
-
963
- </form>
964
-
965
- </div>
966
- <?php
967
-
968
-
969
-
970
- }
971
-
972
-
973
-
974
- /*
975
- IS THE WIDGET PLUGIN LOADED?
976
- If it is, then we provide Widget positioning for ease of use.
977
- */
978
-
979
 
980
  // This is the function that outputs adsensem widget.
981
- function widget($args, $n=0) {
982
-
983
  // $args is an array of strings that help widgets to conform to
984
  // the active theme: before_widget, before_title, after_widget,
985
  // and after_title are the array keys. Default tags: li and h2.
986
  extract($args);
987
-
 
988
  // Each widget can store its own options. We keep strings here.
989
- $options = get_option('plugin_adsensem');
990
- $title = $options['ads'][$n]['title'];
991
 
992
  // These lines generate our output. Widgets can be very complex
993
  // but as you can see here, they can also be very, very simple.
994
  echo $before_widget;
995
- if($title!=''){ echo $before_title . $title . $after_title; }
996
- echo $this->get_ad($options['ads'][$n]); //Output the selected ad
997
  echo $after_widget;
998
  }
999
 
1000
-
1001
-
1002
  /* Widget admin block for each Ad element on the page, allows
1003
  movement of them around the sidebar */
1004
- function widget_control($name)
1005
  {
1006
- $options = get_option('plugin_adsensem');
1007
-
1008
  if ( $_POST['adsensem-' . $name . '-submit'] ) {
 
1009
  // Remember to sanitize and format use input appropriately.
1010
- $options['ads'][$name]['title'] = strip_tags(stripslashes($_POST['adsensem-' . $name . '-title']));
1011
- update_option('plugin_adsensem', $options);
1012
  }
1013
 
1014
  ?>
1015
- <label for="adsensem-<?php echo $name; ?>-title" >Title:</label><input style="width: 200px;" id="adsensem-<?php echo $name; ?>-title" name="adsensem-<?php echo $name; ?>-title" type="text" value="<?php echo htmlspecialchars($options['ads'][$name]['title'], ENT_QUOTES);?>" />
1016
  <input type="hidden" name="adsensem-<?php echo $name; ?>-submit" value="1">
1017
  <?php
1018
 
1019
  }
1020
-
1021
- function admin_add_pages()
1022
- {
1023
- $options = get_option('plugin_adsensem');
1024
-
1025
- add_submenu_page('edit.php',"Ads", "Ads", 10, "adsense-manager-manage", array(&$this,'admin_manage'));
1026
- add_options_page("AdSense Manager Options", "AdSense Manager", 10, "adsense-manager-options", array(&$this,'admin_options'));
1027
-
1028
- /* ADMIN SECTION: WIDGET CONTROL CODE
1029
- /* If SBM installed output the Kludge functions for compatibility */
1030
- /* These use the #id pased via the module name because of inability to pass
1031
- references to functions using class definitions under SBM */
1032
 
1033
- if (function_exists('sbm_get_option') )
1034
- {register_widget_control('AdSense Ad', 'adsensem_sbm_widget_control', 300, 80);}
1035
- /* Add the blocks to the Widget panel for positioning */
1036
- else if (function_exists('wp_register_widget_control') )
1037
- {
1038
-
1039
- /* Loop through available ads and generate widget one at a time */
1040
- if(is_array($options['ads'])){
1041
-
1042
- foreach($options['ads'] as $name => $ad){
1043
- $args = array('n' => $name, 'height' => 80, 'width' => 300);
1044
- wp_register_widget_control('adsensem-' . $name,'Ad #' . $name, array(&$this,'widget_control'), $args, $name);
1045
- }
1046
- }
1047
-
1048
- }
1049
 
1050
-
 
 
 
 
 
1051
  }
1052
 
1053
 
 
1054
  /* This filter parses post content and replaces markup with the correct ad,
1055
  <!--adsense#name--> for named ad or <!--adsense--> for default */
1056
  function filter_ads($content) {
 
1057
 
1058
- $options = get_option('plugin_adsensem');
1059
-
1060
- if(is_array($options['ads'])){
1061
-
1062
  //Insert default ad first
1063
- $content=str_replace("<!--adsense-->",$this->get_ad_inline(false,'default'),$content);
1064
-
1065
- foreach($options['ads'] as $name=>$ad)
1066
- {
1067
- $content = str_replace("<!--adsense#" . $name . "-->", $this->get_ad_inline($ad,$name), $content);
1068
- }
1069
 
 
 
1070
  }
1071
 
1072
  return $content;
1073
  }
1074
 
 
1075
 
1076
- /* Editor functions */
1077
-
1078
-
1079
- /* Add button to simple editor to include AdSense code */
1080
- function admin_callback_editor()
1081
- {
1082
-
1083
- $options = get_option('plugin_adsensem');
1084
-
1085
- //Editor page, so we need to output this editor button code
1086
- if(
1087
- strpos($_SERVER['REQUEST_URI'], 'post.php')
1088
- || strpos($_SERVER['REQUEST_URI'], 'post-new.php')
1089
- || strpos($_SERVER['REQUEST_URI'], 'page.php')
1090
- || strpos($_SERVER['REQUEST_URI'], 'page-new.php')
1091
- || strpos($_SERVER['REQUEST_URI'], 'bookmarklet.php'))
1092
- {
1093
- ?>
1094
- <script language="JavaScript" type="text/javascript">
1095
- <!--
1096
- var ed_adsensem = document.createElement("select");
1097
-
1098
- ed_adsensem.setAttribute("onchange", "add_adsensem(this)");
1099
-
1100
- ed_adsensem.setAttribute("class", "ed_button");
1101
- ed_adsensem.setAttribute("title", "Select AdSense to Add to Content");
1102
- ed_adsensem.setAttribute("id", "ed_adsensem");
1103
-
1104
- adh = document.createElement("option");
1105
- adh.value='';
1106
- adh.innerHTML='AdSense...';
1107
- adh.style.fontWeight='bold';
1108
- ed_adsensem.appendChild(adh);
1109
-
1110
- def = document.createElement("option");
1111
- def.value='';
1112
- def.innerHTML='Default Ad';
1113
-
1114
- ed_adsensem.appendChild(def);
1115
- <?php
1116
-
1117
- if(sizeof($options['ads'])!=0){
1118
- foreach($options['ads'] as $name=>$ad)
1119
- {
1120
- ?> var opt = document.createElement("option");
1121
- opt.value='<?php echo $name; ?>';
1122
- opt.innerHTML='#<?php echo $name; ?>';
1123
- ed_adsensem.appendChild(opt);
1124
- <?php
1125
- }
1126
- }
1127
-
1128
- ?>
1129
- document.getElementById("ed_toolbar").insertBefore(ed_adsensem, document.getElementById("ed_spell"));
1130
-
1131
- /* Below is a Kludge for IE, which causes it to re-read the state of onChange etc. set above. Tut tut tut */
1132
- if (navigator.appName == 'Microsoft Internet Explorer') {
1133
- document.getElementById("ed_toolbar").innerHTML=document.getElementById("ed_toolbar").innerHTML;
1134
- }
1135
-
1136
- function add_adsensem(element)
1137
- {
1138
- if(element.selectedIndex!=0){
1139
-
1140
- if(element.value=='')
1141
- {adsensem_code = '<!--adsense-->';}
1142
- else
1143
- {adsensem_code = '<!--adsense#' + element.value + '-->';}
1144
-
1145
- contentField = document.getElementById("content");
1146
- if (document.selection && !window.opera) {
1147
- // IE compatibility
1148
- contentField.value += adsensem_code;
1149
- } else
1150
- if (contentField.selectionStart || contentField.selectionStart == '0') {
1151
-
1152
- var startPos = contentField.selectionStart;
1153
- var endPos = contentField.selectionEnd;
1154
- contentField.value = contentField.value.substring(0, startPos) + adsensem_code + contentField.value.substring(endPos, contentField.value.length);
1155
-
1156
- } else {
1157
 
1158
- contentField.value += adsensem_code;
1159
- }
1160
- element.selectedIndex=0;
1161
 
1162
- }
1163
- }
1164
- // -->
1165
- </script>
1166
- <?php
1167
- }
1168
-
1169
- }
 
 
 
 
 
 
 
 
 
1170
 
1171
- function activation()
1172
- {
1173
- $options = get_option('plugin_adsensem');
1174
- $updateoptions = false;
1175
-
1176
- if ( !is_array($options) ){
1177
- $options = $this->set_defaults($options,true);
1178
- $updateoptions = true;
1179
- }
1180
-
1181
- //Import from previous versions
1182
- if(!is_numeric($options['be-nice'])){ $options['be-nice'] = ADSENSEM_BE_NICE; }
1183
- $updateoptions = true;
1184
- if($updateoptions){ update_option('plugin_adsensem', $options); }
1185
 
1186
- }
1187
-
1188
- /* Initilisation */
1189
 
1190
- function init()
1191
- {
1192
- $this->activation(); //check variable basics setup on each run...
1193
-
1194
- $options = get_option('plugin_adsensem');
1195
-
1196
- add_action('admin_menu', array(&$this,'admin_add_pages'));
1197
- add_filter('the_content', array(&$this,'filter_ads'));
1198
 
1199
- add_action('admin_footer', array(&$this,'admin_callback_editor'));
1200
-
1201
- /* SITE SECTION: WIDGET DISPLAY CODE
1202
- /* If SBM installed output the Kludge functions for compatibility */
1203
- /* These use the #id pased via the module name because of inability to pass
1204
- references to functions using class definitions under SBM */
1205
- if (function_exists('sbm_get_option') )
1206
- {register_sidebar_widget('AdSense Ad', 'adsensem_sbm_widget');}
1207
- /* Add the blocks to the Widget panel for positioning WP2.2+*/
1208
- else if (function_exists('wp_register_sidebar_widget') )
1209
- {
1210
- /* Loop through available ads and generate widget one at a time */
1211
- if(is_array($options['ads'])){
1212
- foreach($options['ads'] as $name => $ad){
1213
- $args = array('n' => $name);
1214
- //$id, $name, $output_callback, $options = array()
1215
- wp_register_sidebar_widget('adsensem-' . $name,'Ad #' . $name, array(&$this,'widget'), $args, $name);
1216
- wp_register_widget_control('adsensem-' . $name,'Ad #' . $name, array(&$this,'widget_control'), 300, 80);
1217
- }
1218
- }
1219
 
1220
- } else if (function_exists('register_sidebar_widget') )
1221
- /* Add the blocks to the Widget panel for positioning pre WP2.2*/
1222
- {
1223
- /* Loop through available ads and generate widget one at a time */
1224
- if(is_array($options['ads'])){
1225
- foreach($options['ads'] as $name => $ad){
1226
- $args = array('n' => $name);
1227
- //$id, $name, $output_callback, $options = array()
1228
- $widget=array('Ad #%s', '', $name);
1229
- register_sidebar_widget($widget, array(&$this,'widget'), $name);
1230
- register_widget_control($widget, array(&$this,'widget_control'), 300, 80, $name);
1231
- }
1232
- }
1233
-
1234
- }
1235
-
1236
-
1237
-
1238
  }
1239
-
1240
-
 
 
1241
  }
 
1242
 
1243
 
1244
- $adsensem = new adsensem();
1245
-
1246
- /*
1247
- SIDEBAR MODULES COMPATIBILITY KLUDGE
1248
- These functions are external to the class above to allow compatibility with SBM
1249
- which does not allow calls to be passed to a class member.
1250
- These functions are dummy passthru's for the real functions above
1251
-
1252
- SBM also does not pass any details about the module (e.g. module name, id, etc.) to
1253
- the callback function and it is impossible to determine anything about itself.
1254
-
1255
- For this reason the name is extracted out of the title given to the SBM and
1256
- it is not possible to modify individual modules from within the module panel.
1257
- On the upside, it does work.
1258
-
1259
- */
1260
-
1261
- function adsensem_sbm_widget($args){
1262
- global $adsensem;
1263
- extract($args);
1264
- /* The module's title is in 'title'
1265
- we can extract the "name" from this
1266
- and use it to display the correct Ad.
1267
-
1268
- If no matchable title is found, use
1269
- the default Ad */
1270
-
1271
- if( preg_match ("/#(.+)(\W+|$)/", $title, $matches) > 0 )
1272
- { $adsensem->widget($args,$matches[1]); }
1273
- else { $adsensem->widget($args); }
1274
- }
1275
-
1276
- function adsensem_sbm_widget_control(){
1277
- /*Null function, unable to edit options for multiple Widgets under SBM*/
1278
- }
1279
-
1280
- /*
1281
- END DUMMY KLUDGE
1282
- */
1283
 
1284
- // Run our code later in case this loads prior to any required plugins.
1285
- add_action('plugins_loaded', array(&$adsensem,'init'));
1286
- //register_activation_hook('adsense-manager', array(&$this,'activation'));
1287
 
1288
  ?>
4
  PLugin URI: http://wordpress.org/extend/plugins/adsense-manager/
5
  Description: Control and arrange your AdSense & Referral blocks on your Wordpress blog. With Widget and inline post support, configurable colours.
6
  Author: Martin Fitzpatrick
7
+ Version: 3.0
8
  Author URI: http://www.mutube.com/
9
  */
10
 
17
 
18
  */
19
 
20
+ @define("ADSENSEM_VERSION", "3.0");
21
  @define('ADSENSEM_DIRPATH','/wp-content/plugins' . strrchr(dirname(__FILE__),'/') . "/");
22
 
23
  /*
25
  */
26
 
27
  //Currently not used
28
+ //@define("ADSENSEM_MAX_ADS", 7); //Max Google Ad units
29
+ //@define("ADSENSEM_MAX_REFERRALS", 7); //Max Google Referral units
30
 
31
  @define("ADSENSEM_BE_NICE", 3); //Default level only, can be changed in Options/AdSense Manager
 
 
 
32
 
33
 
34
  /* Copyright 2006 MARTIN FITZPATRICK (email : martin.fitzpatrick@gmail.com)
48
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
49
  */
50
 
51
+ //Now ad networks are managed by dedicated classes. How modern.
52
+ require_once('class-generic.php');
53
+
54
+ require_once('class-adsense.php'); //Adsense (using Slots, etc.)
55
+
56
+ require_once('class-adsense-classic.php'); //AdSense units pre-slot style
57
+ require_once('class-adsense-ad.php'); //AdSense Ad units pre-slot style
58
+ require_once('class-adsense-link.php'); //AdSense Link units pre-slot style
59
+ require_once('class-adsense-referral.php'); //AdSense Referral units pre-slot style
60
+
61
+ require_once('class-adpinion.php'); //Adpinion
62
+ require_once('class-adroll.php'); //AdRoll
63
+ require_once('class-adbrite.php'); //AdBrite
64
+ require_once('class-cj.php'); //Commission Junction
65
+ //require('class-ypn.php'); //Yahoo! Publisher Network - not yet supported
66
+ require_once('class-code.php'); //HTML Code
67
+ require_once('class-shoppingads.php'); //ShoppingAds
68
+ require_once('class-widgetbucks.php'); //Widgetbucks
69
+
70
+ if(is_admin()){ require_once('class-admin.php'); } //Admin interface functions (keep out while browsing main site
71
+
72
+ $_adsensem = get_option('plugin_adsensem');
73
+ $_adsensem_notices = array();
74
+
75
 
76
  /*
77
 
83
  */
84
 
85
  //Kept external for backward compatibility
86
+ if(!function_exists('adsensem_ad')) {
87
+ function adsensem_ad($name=false) {
88
+ global $_adsensem;
89
+ if($name===false)
90
+ {$ad=$_adsensem['ads'][$_adsensem['default-ad']];}
91
+ else
92
+ {$ad=$_adsensem['ads'][$name];}
93
+ echo adsensem::get_ad($ad,$name);
94
+ }
 
 
 
 
 
 
95
  }
96
 
97
 
 
98
  /*
99
 
100
  INITIALISATION
103
  */
104
 
105
  class adsensem {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
+ //STARTUP INITIALISATION
108
+ function init(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
+ global $_adsensem;
 
 
111
 
112
+ //Only run main site code if setup & functional
113
+ if(adsensem::setup_is_valid()){
114
+ add_filter('the_content', array('adsensem','filter_ads'));
115
+ add_action('wp_footer', array('adsensem','footer'));
116
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
+ add_action('admin_menu', array('adsensem_admin','init_admin'));
119
+ add_action('admin_head', array('adsensem_admin','add_header_script'));
120
+ add_action('admin_footer', array('adsensem_admin','admin_callback_editor'));
121
 
 
 
 
 
 
 
 
122
  }
 
 
 
 
123
 
124
+ function setup_is_valid(){
125
+ global $_adsensem;
126
+ if(is_array($_adsensem)){
127
+ if(is_array($_adsensem['ads'])){
128
+ if(is_object($_adsensem['ads'][$_adsensem['default-ad']])){
129
+ return true;
 
 
 
 
 
130
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  }
132
  }
133
+ return false;
 
 
 
 
 
 
134
  }
135
+
136
+ function init_widgets()
137
+ {
138
+ global $_adsensem;
139
+ /* SITE SECTION: WIDGET DISPLAY CODE
140
+ /* Add the blocks to the Widget panel for positioning WP2.2+*/
141
+ $args = array('n' => $name, 'height' => 80, 'width' => 300);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
+ if (function_exists('wp_register_sidebar_widget') )
144
+ {
145
+ /* Loop through available ads and generate widget one at a time */
146
+ if(is_array($_adsensem['ads'])){
147
+ foreach($_adsensem['ads'] as $name => $ad){
148
+ $args = array('n' => $name, 'height' => 80, 'width' => 300);
149
+ //$id, $name, $output_callback, $_adsensem = array()
150
+ wp_register_sidebar_widget('adsensem-' . $name,'Ad #' . $name, array('adsensem','widget'), $args, $name);
151
+ wp_register_widget_control('adsensem-' . $name,'Ad #' . $name, array('adsensem','widget_control'), $args, $name);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  }
153
+ }
154
 
155
+ }
 
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
  // This is the function that outputs adsensem widget.
161
+ function widget($args, $n=0) {
 
162
  // $args is an array of strings that help widgets to conform to
163
  // the active theme: before_widget, before_title, after_widget,
164
  // and after_title are the array keys. Default tags: li and h2.
165
  extract($args);
166
+ global $_adsensem;
167
+
168
  // Each widget can store its own options. We keep strings here.
169
+ $ad = $_adsensem['ads'][$n];
 
170
 
171
  // These lines generate our output. Widgets can be very complex
172
  // but as you can see here, they can also be very, very simple.
173
  echo $before_widget;
174
+ if($ad->title!=''){ echo $before_title . $ad->title . $after_title; }
175
+ echo $ad->get_ad(); //Output the selected ad
176
  echo $after_widget;
177
  }
178
 
 
 
179
  /* Widget admin block for each Ad element on the page, allows
180
  movement of them around the sidebar */
181
+ function widget_control($name)
182
  {
183
+ global $_adsensem;
184
+
185
  if ( $_POST['adsensem-' . $name . '-submit'] ) {
186
+ global $_adsensem;
187
  // Remember to sanitize and format use input appropriately.
188
+ $_adsensem['ads'][$name]->title = strip_tags(stripslashes($_POST['adsensem-' . $name . '-title']));
189
+ update_option('plugin_adsensem', $_adsensem);
190
  }
191
 
192
  ?>
193
+ <label for="adsensem-<?php echo $name; ?>-title" >Title:</label><input style="width: 200px;" id="adsensem-<?php echo $name; ?>-title" name="adsensem-<?php echo $name; ?>-title" type="text" value="<?php echo htmlspecialchars($_adsensem['ads'][$name]->title, ENT_QUOTES);?>" />
194
  <input type="hidden" name="adsensem-<?php echo $name; ?>-submit" value="1">
195
  <?php
196
 
197
  }
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
+
202
+
203
+
204
+
205
+ function footer(){
206
+ ?><!-- AdSense Manager v<?php echo ADSENSEM_VERSION;?> (<?php timer_stop(1); ?> seconds.) --><?php
207
  }
208
 
209
 
210
+
211
  /* This filter parses post content and replaces markup with the correct ad,
212
  <!--adsense#name--> for named ad or <!--adsense--> for default */
213
  function filter_ads($content) {
214
+ global $_adsensem;
215
 
216
+ if(is_object($_adsensem['ads'][$_adsensem['default-ad']])){
 
 
 
217
  //Insert default ad first
218
+ $content=str_replace(array("<!--adsense-->","<!--am-->"),$_adsensem['ads'][$_adsensem['default-ad']]->get_ad(),$content);
 
 
 
 
 
219
 
220
+ foreach($_adsensem['ads'] as $name=>$ad)
221
+ { $content = str_replace(array("<!--adsense#" . $name . "-->","<!--am#" . $name . "-->"), $ad->get_ad(), $content); }
222
  }
223
 
224
  return $content;
225
  }
226
 
227
+ }
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
 
 
 
230
 
231
+ /* SHOW ALTERNATE AD UNITS */
232
+ if ($_REQUEST['adsensem-show-ad']){
233
+ ?><html><body><?php
234
+ adsensem_ad($_REQUEST['adsensem-show-ad']);
235
+ ?></body></html><?php
236
+ die(0);
237
+ }
238
+ /* END SHOW ALTERNATE AD UNITS */
239
+
240
+ /* SHOW BENICE UNITS */
241
+ if ($_REQUEST['adsensem-benice']){
242
+ ?><html><body><?php
243
+ echo adsensem_benice::benice_code($_REQUEST['adsensem-benice']); //contains format
244
+ ?></body></html><?php
245
+ die(0);
246
+ }
247
+ /* END BENICE UNITS */
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
 
 
 
 
250
 
 
 
 
 
 
 
 
 
251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
+ /* PRE-OUTPUT PROCESSING - e.g. NOTICEs (upgrade-adsense-deluxe) */
254
+ switch ($_POST['adsensem-mode'].':'.$_POST['adsensem-action']){
255
+ case 'notice:upgrade adsense-deluxe':
256
+ if($_POST['adsensem-notice-confirm-yes']){
257
+ require('class-upgrade.php');
258
+ adsensem_upgrade::adsense_deluxe_to_3_0();
259
+ adsensem_admin::remove_notice('upgrade adsense-deluxe');
260
+ } else {
261
+ adsensem_admin::remove_notice('upgrade adsense-deluxe');
 
 
 
 
 
 
 
 
 
262
  }
263
+ break;
264
+ case 'notice:upgrade adsense-manager':
265
+ adsensem_admin::remove_notice('upgrade adsense-manager');
266
+ break;
267
  }
268
+ /* END PRE-OUTPUT PROCESSING */
269
 
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
 
272
+ add_action('plugins_loaded', array('adsensem','init'), 1);
273
+ add_action('widgets_init', array('adsensem','init_widgets'), 1);
 
274
 
275
  ?>
class-adbrite.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_AdBrite'] = array(
6
+ 'name' => 'AdBrite',
7
+ 'shortname' => 'adbrite',
8
+ 'www' => 'http://www.adbrite.com/',
9
+ 'www-create' => 'http://www.adbrite.com/zones/commerce/purchase.php?product_id_array=22',
10
+ 'www-signup' => 'http://www.adbrite.com/mb/landing_both.php?spid=51549&afb=120x60-1-blue',
11
+ );
12
+
13
+ /*
14
+
15
+ INITIALISATION
16
+ All functions in here called at startup (after other plugins have loaded, in case
17
+ we need to wait for the widget-plugin).
18
+ */
19
+
20
+ class Ad_AdBrite extends Ad_Generic {
21
+
22
+ function Ad_AdBrite(){
23
+ $this->Ad_Generic();
24
+ }
25
+
26
+ function render_ad(){
27
+
28
+ /* <!-- Begin: AdBrite -->
29
+ <script type="text/javascript">
30
+ var AdBrite_Title_Color = '0000FF';
31
+ var AdBrite_Text_Color = '000000';
32
+ var AdBrite_Background_Color = 'FFFFFF';
33
+ var AdBrite_Border_Color = 'FFFFFF';
34
+ </script>
35
+ <script src="http://ads.adbrite.com/mb/text_group.php?sid=426554&zs=3132305f363030" type="text/javascript"></script>
36
+ <div><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=426554&afsid=1" style="font-weight:bold;font-family:Arial;font-size:13px;">Your Ad Here</a></div>
37
+ <!-- End: AdBrite -->
38
+ */
39
+
40
+ $code ='<!-- Begin: AdBrite -->';
41
+ $code .= '<script type="text/javascript">' . "\n";
42
+ $code .= "var AdBrite_Title_Color = '" . $this->pd('color-title') . "'\n";
43
+ $code .= "var AdBrite_Text_Color = '" . $this->pd('color-text') . "'\n";
44
+ $code .= "var AdBrite_Background_Color = '" . $this->pd('color-bg') . "'\n";
45
+ $code .= "var AdBrite_Border_Color = '" . $this->pd('color-border') . "'\n";
46
+ $code .= '</script>' . "\n";
47
+ $code .= '<script src="http://ads.adbrite.com/mb/text_group.php?sid=' . $this->account_id() . '&zs=' . $this->pd('slot') . '" type="text/javascript"></script>';
48
+ $code .= '<div><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=' . $this->account_id() . '&afsid=1" style="font-weight:bold;font-family:Arial;font-size:13px;">Your Ad Here</a></div>';
49
+ $code .= '<!-- End: AdBrite -->';
50
+
51
+ return $code;
52
+ }
53
+
54
+
55
+ function save_settings_network() {
56
+
57
+ $this->p['slot']=strip_tags(stripslashes($_POST['adsensem-slot']));
58
+ $this->p['code']=stripslashes($_POST['adsensem-code']);
59
+
60
+ $this->p['color-border']=strip_tags(stripslashes($_POST['adsensem-color-border']));
61
+ $this->p['color-title']=strip_tags(stripslashes($_POST['adsensem-color-title']));
62
+ $this->p['color-bg']=strip_tags(stripslashes($_POST['adsensem-color-bg']));
63
+ $this->p['color-text']=strip_tags(stripslashes($_POST['adsensem-color-text']));
64
+
65
+ }
66
+
67
+
68
+ function reset_defaults_network() {
69
+ global $_adsensem;
70
+ $_adsensem['defaults'][$this->network()]+= array (
71
+ 'color-border'=> 'FFFFFF',
72
+ 'color-title' => '0000FF',
73
+ 'color-bg' => 'FFFFFF',
74
+ 'color-text' => '000000',
75
+
76
+ 'slot' => '',
77
+
78
+ 'adformat' => '250x250',
79
+ );
80
+ }
81
+
82
+
83
+ function import_detect_network($code){
84
+
85
+ return ( (strpos($code,'<!-- Begin: AdBrite -->')!==false) ||
86
+ (strpos($code,'src="http://ads.adbrite.com')!==false) ||
87
+ (strpos($code,'<!-- End: AdBrite -->')!==false)
88
+ );
89
+
90
+ }
91
+
92
+ function import_settings($code){
93
+
94
+
95
+ //Load data up into the $_POST variables, then call save_settings??
96
+ /* <!-- Begin: AdBrite -->
97
+ <script type="text/javascript">
98
+ var AdBrite_Title_Color = '0000FF';
99
+ var AdBrite_Text_Color = '000000';
100
+ var AdBrite_Background_Color = 'FFFFFF';
101
+ var AdBrite_Border_Color = 'FFFFFF';
102
+ </script>
103
+ <script src="http://ads.adbrite.com/mb/text_group.php?sid=426554&zs=3132305f363030" type="text/javascript"></script>
104
+ <div><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=426554&afsid=1" style="font-weight:bold;font-family:Arial;font-size:13px;">Your Ad Here</a></div>
105
+ <!-- End: AdBrite -->
106
+ */
107
+
108
+ if(preg_match('/var AdBrite_Title_Color = \'(\w*)\'/', $code, $matches)!=0){ $_POST['adsensem-color-title'] = $matches[1]; }
109
+ if(preg_match("/var AdBrite_Text_Color = '(\w*)'/", $code, $matches)!=0){ $_POST['adsensem-color-text'] = $matches[1]; }
110
+ if(preg_match("/var AdBrite_Background_Color = '(\w*)'/", $code, $matches)!=0){ $_POST['adsensem-color-bg'] = $matches[1]; }
111
+ if(preg_match("/var AdBrite_Border_Color = '(\w*)'/", $code, $matches)!=0){ $_POST['adsensem-color-border'] = $matches[1]; }
112
+
113
+ //ACCOUNT ID? NEEDS DEFAULT IMPORT RULES. GAH.
114
+ //if(preg_match("/sid=(.*)&/", $code, $matches)!=0){ $_POST['adsensem-color-border'] = $matches[1]; }
115
+ if(preg_match("/zs=(\w*)/", $code, $matches)!=0){$_POST['adsensem-account-id'] = $matches[1]; }
116
+ if(preg_match("/sid=(\w*)/", $code, $matches)!=0){$_POST['adsensem-slot'] = $matches[1]; }
117
+
118
+ $this->save_settings();
119
+ }
120
+
121
+
122
+ function _form_settings_colors(){
123
+ $this->_form_settings_colors_generate(array('Border'=>'border','Title'=>'title','Background'=>'bg','Text'=>'text'));
124
+ }
125
+
126
+
127
+ function _form_settings_colors_demo(){
128
+ ?>
129
+ <div id="ad-color-bg" style="margin-top:1em;width:120px;background: #<?php echo htmlspecialchars($this->pd('color-bg'), ENT_QUOTES); ?>;">
130
+ <div id="ad-color-border" style="font: 10px arial, sans-serif; border: 1px solid #<?php echo htmlspecialchars($this->pd('color-border'), ENT_QUOTES); ?>" class="linkunit-wrapper">
131
+ <div id="ad-color-title" style="color: #<?php echo htmlspecialchars($this->pd('color-title'), ENT_QUOTES); ?>; font: 11px verdana, arial, sans-serif; padding: 2px;">
132
+ <b><u>Linked Title</u></b><br /></div>
133
+ <div id="ad-color-text" style="color: #<?php echo htmlspecialchars($this->pd('color-text'), ENT_QUOTES); ?>; padding: 2px;" class="text">
134
+ Advertiser's ad text here<br /></div>
135
+ <div id="ad-color-link" style="color: #<?php echo htmlspecialchars($this->pd('color-title'), ENT_QUOTES); ?>; font: 10px verdana, arial, sans-serif; padding: 2px;">
136
+ www.advertiser-url.com<br /></div>
137
+ <div style="color: #000; padding: 2px;" class="rtl-safe-align-right">
138
+ &nbsp;<u>Ads by AdBrite</u></div>
139
+ </div>
140
+ <?php
141
+ }
142
+
143
+ function _var_ad_formats_available(){
144
+ $formats['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner');
145
+ $formats['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper');
146
+ $formats['square']=array('300x250' => '300 x 250 Medium Rectangle');
147
+ return $formats;
148
+ }
149
+
150
+
151
+ }
152
+
153
+ ?>
class-admin.php ADDED
@@ -0,0 +1,890 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /*
5
+
6
+ INITIALISATION
7
+ All functions in here called at startup (after other plugins have loaded, in case
8
+ we need to wait for the widget-plugin).
9
+ */
10
+
11
+ class adsensem_admin {
12
+
13
+ function init_admin()
14
+ {
15
+ global $_adsensem;
16
+
17
+ wp_enqueue_script('prototype');
18
+ wp_enqueue_script('dbx');
19
+ wp_enqueue_script('dbx-admin-key');
20
+
21
+ add_submenu_page('edit.php',"Ad Units", "Ad Units", 10, "adsense-manager-manage-ads", array('adsensem_admin','admin_manage'));
22
+ // add_submenu_page('edit.php',"Ad Zones", "Ad Zones", 10, "adsense-manager-manage-ad-zones", 'adsensem_admin::admin_manage');
23
+ add_options_page("AdSense Manager Options", "AdSense Manager", 10, "adsense-manager-options", array('adsensem_admin','admin_options'));
24
+ add_action( 'admin_notices', array('adsensem_admin','admin_notices'), 1 );
25
+
26
+ if (!is_array($_adsensem)){ //No startup data found, fill it out now.
27
+
28
+ /* Wipe basic data */
29
+ //'demo-adroll' => new Ad_ShoppingAds,
30
+ $_adsensem['ads'] = array();
31
+ $_adsensem['defaults'] = array();
32
+ $_adsensem['account-ids'] = array();
33
+
34
+ $_adsensem['be-nice'] = ADSENSEM_BE_NICE;
35
+ $_adsensem['version'] = ADSENSEM_VERSION;
36
+
37
+ $deluxe=get_option('acmetech_adsensedeluxe');
38
+ if(is_array($deluxe)){adsensem_admin::add_notice('upgrade adsense-deluxe','AdSense Manager has detected a previous installation of <strong>AdSense Deluxe</strong>. Import settings?','yn');}
39
+
40
+ $update_adsensem = true;
41
+
42
+ } else if($_adsensem['version']<ADSENSEM_VERSION){
43
+ require('class-upgrade.php');
44
+ update_option('plugin_adsensem_backup',$_adsensem);
45
+
46
+ adsensem_upgrade::go();
47
+ adsensem_admin::add_notice('upgrade adsense-manager','AdSense Manager has detected a previous installation and automatically upgraded your settings','ok');
48
+ $update_adsensem=true;
49
+ }
50
+
51
+ if($update_adsensem){ update_option('plugin_adsensem', $_adsensem); }
52
+
53
+ }
54
+
55
+ /*
56
+ NOTIFICATION FUNCTIONS
57
+ Functions below output notices to update the user on import options, issues with the data imported etc.
58
+ */
59
+
60
+
61
+ function admin_notices(){
62
+ global $_adsensem;
63
+ ?>
64
+ <?php
65
+ if(is_array($_adsensem['notices'])){
66
+ foreach($_adsensem['notices'] as $action=>$notice){
67
+ ?>
68
+ <div id='update-nag'>
69
+ <form action="edit.php?page=adsense-manager-manage-ads" method="post" id="adsensem-config-manage" enctype="multipart/form-data">
70
+ <input type="hidden" name="adsensem-mode" value="notice">
71
+ <input type="hidden" name="adsensem-action" value="<?php echo $action; ?>">
72
+ <?php echo str_replace('AdSense Manager','<strong>AdSense Manager</strong>',$notice['text']); ?>
73
+ <?php if($notice['confirm']=='yn'){ ?>
74
+ <input name="adsensem-notice-confirm-yes" type="submit" value="Yes">
75
+ <input name="adsensem-notice-confirm-no" type="submit" value="No">
76
+ <?php } else if($notice['confirm']=='ok'){ ?>
77
+ <input name="adsensem-notice-confirm-ok" type="submit" value="OK">
78
+ <?php } ?>
79
+ </form>
80
+ </div><?php
81
+ }
82
+ }
83
+
84
+ }
85
+
86
+ function add_notice($action,$text,$confirm=false){
87
+ global $_adsensem;
88
+ //if($_adsensem['notices'][$action]!==false){ //Has not previously been disabled
89
+ $_adsensem['notices'][$action]['text']=$text;
90
+ $_adsensem['notices'][$action]['confirm']=$confirm;
91
+ //}
92
+ update_option('plugin_adsensem', $_adsensem);
93
+ }
94
+
95
+ function remove_notice($action){
96
+ global $_adsensem;
97
+ unset($_adsensem['notices'][$action]); //=false;
98
+ update_option('plugin_adsensem', $_adsensem);
99
+ }
100
+
101
+
102
+
103
+
104
+
105
+ /*
106
+ FORM ELEMENT GENERATION FUNCTIONS
107
+ Following functions are responsible for outputting the form elements while editing ad units
108
+ */
109
+
110
+
111
+ function _field_select_options($list,$selected){
112
+ foreach($list as $key=>$value)
113
+ {
114
+ if(is_array($value)){
115
+ ?><optgroup id="adsensem-optgroup-<?php echo $key; ?>" label="<?php echo ucwords($key); ?>"><?php adsensem_admin::_field_select_options($value,$selected); ?></optgroup><?php
116
+ } else {
117
+ ?><option <?php if($key==$selected){ echo "selected"; }?> value="<?php echo $key; ?>"> <?php echo $value; ?></option><?php
118
+ }
119
+ }
120
+ }
121
+
122
+ function _field_select($title,$id,$list,$selected)
123
+ {
124
+ $default=array('' => 'Use Default');
125
+ if(is_array(current($list))){$default=array('Default'=>$default);} //If optgroups in use, move the default into one. Smart.
126
+ ?>
127
+ <tr id="adsensem-form-<?php echo $id;?>"><td class="adsensem_label"><label for="adsensem-<?php echo $id?>"><?php echo $title?>:</label></td><td>
128
+ <select name="adsensem-<?php echo $id; ?>" id="adsensem-<?php echo $id; ?>" onchange="adsensem_form_update(this);">
129
+ <?php if($_POST['adsensem-action']!=='edit defaults'){ ?><?php adsensem_admin::_field_select_options($default,$selected);?><?php }
130
+ adsensem_admin::_field_select_options($list,$selected);
131
+ ?></select>
132
+ </td></tr>
133
+ <?php
134
+ }
135
+
136
+ function _field_input($title,$id,$value,$size,$info='')
137
+ {
138
+ ?>
139
+ <tr id="adsensem-form-<?php echo $id;?>"><td class="adsensem_label"><label for="adsensem-<?php echo $id;?>"><?php echo $title;?>:</label></td><td>
140
+ <input name="adsensem-<?php echo $id;?>" size="<?php echo $size;?>" title="<?php echo $info;?>" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?>" />
141
+ </td></tr>
142
+ <?php
143
+ }
144
+
145
+ //Reads an array and outputs the form elements specified within, wrapped in the dbx wrapper code.
146
+ function manage_dbxoutput($forms){
147
+ ?>
148
+
149
+ <?php
150
+ foreach($forms as $formelement){
151
+ ?><div class="dbx-box-wrapper">
152
+ <fieldset id="<?php $formelement; ?>" class="dbx-box">
153
+ <div class="dbx-handle-wrapper"><h3 class="dbx-handle"><?php echo ucwords(strtr($formelement,'_',' ')); ?></h3></div>
154
+ <div class="dbx-content-wrapper">
155
+ <div class="dbx-content">
156
+ <div><table id="adsensem-settings-<?php echo $formelement; ?>"><?php $this->{_form_settings_.$formelement}(); ?></table></div>
157
+ </div>
158
+ </div>
159
+ </fieldset></div><?php
160
+ }
161
+
162
+
163
+ }
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ /*
172
+ NETWORK LISTING / AD SORTING FUNCTIONS
173
+ Functions below sort and list networks available and the ads running on them
174
+ */
175
+
176
+
177
+ function network_list(){
178
+ global $_adsensem_networks;
179
+
180
+ $count=sizeof($_adsensem_networks);
181
+ foreach($_adsensem_networks as $name=>$network){
182
+ $count--;
183
+
184
+ if( $network['display']===false ) { continue; }
185
+ if( $network['www-signup']!='' ){ ?><a href="<?php echo $network['www-signup'] ?>" target="_blank"><?php }
186
+ echo $network['name'];
187
+ if( $network['www-signup']!='' ){ ?></a><?php }
188
+
189
+ if($count>1){echo ', ';} else if($count==1){echo ' and ';}
190
+ }
191
+
192
+ }
193
+
194
+ function sort_ad_step($a,$b){
195
+ $sort_network=strcmp( $GLOBALS['_adsensem_sort_ads_by_network'][$a]->network(), $GLOBALS['_adsensem_sort_ads_by_network'][$b]->network() );
196
+
197
+ if($sort_network==0){ //Same network, sort name
198
+ return strcmp($a,$b);
199
+ } else {return $sort_network;}
200
+ }
201
+
202
+ /* Sort ads by the network they're on, allows Manage Ads display to show grouped */
203
+ function sort_ads_by_network($ads){
204
+ $GLOBALS['_adsensem_sort_ads_by_network']=$ads; //Needed to pass data into the comparison function
205
+ uksort($ads,array('adsensem_admin','sort_ad_step'));
206
+ $GLOBALS['_adsensem_sort_ads_by_network']='';
207
+ return $ads;
208
+ }
209
+
210
+
211
+
212
+
213
+
214
+ /*
215
+ IMPORTING AND SAVING FUNCTIONS
216
+ Functions below are for running the import process from ad network code and for checking the validity
217
+ of submitted values, e.g. for names
218
+ */
219
+
220
+
221
+ function import_ad($code){
222
+ global $_adsensem_networks;
223
+ $imported=false;
224
+
225
+ //We're attempting to import code
226
+ $code=stripslashes($code);
227
+ foreach ($_adsensem_networks as $network => $n){
228
+ if(call_user_func(array($network,'import_detect_network'),$code))
229
+ {
230
+ $ad=new $network;
231
+ $ad->import_settings($code);
232
+
233
+ $imported=true;
234
+ break; //leave the foreach loop
235
+ }
236
+ }
237
+
238
+ if(!$imported){$ad=new Ad_Code(); $ad->import_settings($code);}
239
+ return $ad;
240
+ }
241
+
242
+ function validate_name($name,$network=false){
243
+ global $_adsensem,$_adsensem_networks;
244
+ $name=sanitize_title($name);
245
+
246
+ if($name==''){
247
+ if($network){ $base=$_adsensem_networks[$network]['shortname']; }
248
+ else { $base='ad'; }
249
+ } else { $base=$name; }
250
+
251
+ $a=0;
252
+ while (isset($_adsensem['ads'][$name]) || ($name=='')){
253
+ $a++; $name=$base . '-' . $a;
254
+ }
255
+
256
+ return $name;
257
+ }
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+ /*
266
+ PROCESS ADMIN/EDITING SUBMISSION
267
+ Takes submission from the admin Manage ads area and processes it to save results, import code & update
268
+ */
269
+
270
+
271
+ /* Define and manage AdSense ad blocks for your Wordpress setup */
272
+ function admin_manage() {
273
+
274
+ // Get our options and see if we're handling a form submission.
275
+ global $_adsensem, $_adsensem_networks;
276
+
277
+ $update_adsensem=false;
278
+ ;
279
+ /* Submissions from the manage ads listing at the top of the page */
280
+ //if ( $_POST['adsensem-submit']=='manage' ) {
281
+ switch ($_POST['adsensem-mode'].':'.$_POST['adsensem-action']){
282
+
283
+ case 'manage:copy unit':
284
+ //Copy selected advert
285
+ $copyto=adsensem_admin::validate_name($_POST['adsensem-action-target']);
286
+ $_adsensem['ads'][$copyto]=clone $_adsensem['ads'][$_POST['adsensem-action-target']];
287
+ $_adsensem['ads'][$copyto]->name=$copyto; //update internal name reference
288
+ $_adsensem['ads']=adsensem_admin::sort_ads_by_network($_adsensem['ads']);
289
+ $update_adsensem=true;
290
+ break;
291
+
292
+ case 'manage:delete unit':
293
+ //Delete selected advert
294
+ if($_POST['adsensem-action-target']!=$_adsensem['default-ad']){
295
+ unset($_adsensem['ads'][$_POST['adsensem-action-target']]);
296
+ $update_adsensem=true;
297
+ }
298
+ break;
299
+
300
+ case 'manage:set default':
301
+ //Set selected advert as default
302
+ $_adsensem['default-ad']=$_POST['adsensem-default-name'];
303
+ $update_adsensem=true;
304
+ break;
305
+
306
+ case 'save:edit new':
307
+ $name=adsensem_admin::validate_name($_POST['adsensem-name']);
308
+ $_adsensem['ads'][$name] = new $_POST['adsensem-action-target']; //temporary to access network-specific functions
309
+
310
+ $_adsensem['ads'][$name]->name=$name; //Update internal name reference (always, to ensure accuracy)
311
+ $_adsensem['ads'][$name]->save_settings();
312
+
313
+ $_POST['adsensem-mode']='manage';
314
+ $_POST['adsensem-action']='';
315
+ $update_adsensem=true;
316
+ break;
317
+
318
+ case 'save:edit unit':
319
+ case 'apply:edit unit':
320
+ /* Changing the name of an Ad, copy and delete old */
321
+ if($_POST['adsensem-name']!=$_POST['adsensem-name-old']){
322
+ $name=adsensem_admin::validate_name($_POST['adsensem-name']);
323
+ $_adsensem['ads'][$name]=clone $_adsensem['ads'][$_POST['adsensem-name-old']];
324
+ //$_adsensem['ads'][$name]->name=$name; //Update object-held name
325
+ unset($_adsensem['ads'][$_POST['adsensem-name-old']]);
326
+ /* We can now use the new $name from this point forward, lovely */
327
+ /* Update default if neccessary */
328
+ if($_adsensem['default-ad']==$_POST['adsensem-name-old']){$_adsensem['default-ad']=$name;}
329
+ $_adsensem['ads'][$name]->name=$name; //Update internal name reference (always, to ensure accuracy)
330
+
331
+ } else {$name=stripslashes($_POST['adsensem-name']);}
332
+
333
+ $_adsensem['ads'][$name]->save_settings();
334
+
335
+ if($_POST['adsensem-mode']!=='apply'){//Only for Save (Apply leave as is, return to edit page)
336
+ $_POST['adsensem-mode']='manage';
337
+ $_POST['adsensem-action']='';}
338
+
339
+ $update_adsensem=true;
340
+ break;
341
+
342
+ case 'save:restore defaults':
343
+ $temp = new $_POST['adsensem-action-target']; //temporary to access network-specific functions
344
+ $temp->reset_defaults();
345
+
346
+ $_POST['adsensem-mode']='edit';
347
+ $_POST['adsensem-action']='edit defaults';
348
+ $update_adsensem=true;
349
+ break;
350
+
351
+ case 'save:edit defaults':
352
+ $temp = new $_POST['adsensem-action-target']; //temporary to access network-specific functions
353
+ $temp->save_settings();
354
+
355
+ $_adsensem['defaults'][$_POST['adsensem-action-target']]=$temp->p;
356
+
357
+ $_POST['adsensem-mode']='manage';
358
+ $_POST['adsensem-action']='';
359
+ $update_adsensem=true;
360
+ break;
361
+
362
+ case 'import:edit code':
363
+ $ad=new Ad_Code;
364
+ $ad->save_settings(); //adsensem_admin::import_ad($_POST['adsensem-code']);
365
+ $name=adsensem_admin::validate_name($_POST['adsensem-name'],$ad->network());
366
+ $_adsensem['ads'][$name]=$ad;
367
+ $_adsensem['ads'][$name]->name=$name;
368
+
369
+ //Forces imported unit into the edit mode for changes
370
+ $_POST['adsensem-action']='edit unit';
371
+ $_POST['adsensem-action-target']=$name;
372
+
373
+ $update_adsensem=true; $sort_adsensem=true;
374
+ break;
375
+
376
+ case 'import:edit unit':
377
+ $ad=adsensem_admin::import_ad($_POST['adsensem-code']);
378
+ $name=adsensem_admin::validate_name($_POST['adsensem-name'],$ad->network());
379
+ $_adsensem['ads'][$name]=$ad;
380
+ $_adsensem['ads'][$name]->name=$name;
381
+
382
+ //Ensure that account-id passed to defaults when it does not match current submission
383
+ //if($_adsensem['defaults'][$ad->network()]['account-id']!==$ad->p['account-id']){$_adsensem['defaults'][$ad->network()]['account-id']=$ad->p['account-id'];}
384
+
385
+ //Forces imported unit into the edit mode for changes
386
+ $_POST['adsensem-action']='edit unit';
387
+ $_POST['adsensem-action-target']=$name;
388
+
389
+ $update_adsensem=true;
390
+ break;
391
+
392
+ case 'import:edit defaults':
393
+ $ad=adsensem_admin::import_ad($_POST['adsensem-code']);
394
+ if($ad->network=='Ad_Code'){$_POST['adsensem-action']=''; break;}
395
+
396
+ $_adsensem['defaults'][$ad->network()]=$ad->p;
397
+
398
+ //Forces imported unit into the edit mode for changes, to skip change mode to 'manage';
399
+ $_POST['adsensem-action']='edit defaults';
400
+ $_POST['adsensem-action-target']=$ad->network();
401
+
402
+ $update_adsensem=true;
403
+ break;
404
+
405
+ case 'manage:edit unit': //Pass through stuff to switch modes between pages.
406
+ case 'manage:edit defaults':
407
+ case 'import:edit new':
408
+ $_POST['adsensem-mode']='edit';
409
+ break;
410
+
411
+ default:
412
+ $_POST['adsensem-mode']='manage';
413
+ $_POST['adsensem-action']='';
414
+
415
+ } //End switch cases
416
+
417
+ //Set default ad if it is currently incorrect and there is a valid ad object available
418
+ if( (!is_object($_adsensem['ads'][$_adsensem['default-ad']]) ) && ( count($_adsensem['ads']>0) ) ){
419
+ $_adsensem['default-ad']=key($_adsensem['ads']);
420
+ $update_adsensem==true;
421
+ }
422
+
423
+ if($update_adsensem){
424
+ $_adsensem['ads']=adsensem_admin::sort_ads_by_network($_adsensem['ads']);
425
+ update_option('plugin_adsensem', $_adsensem);
426
+ }
427
+
428
+ if($_POST['adsensem-mode']=='manage'){ //Managing (i.e. not Importing, or editing)
429
+ //If not in edit mode, output the ad listing/tables
430
+ ////if((sizeof($_adsensem['ads'])==false) || (sizeof($_adsensem['ads'])==0) ){
431
+ adsensem_admin::admin_manage_table(); //Only if ads available to list
432
+ // }
433
+ adsensem_admin::admin_manage_create();
434
+ } else {
435
+ //If in edit mode, output the editing form (create, edit, defaults, etc.)
436
+ adsensem_admin::admin_manage_edit();
437
+ }
438
+
439
+
440
+
441
+ }
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+ /*
450
+ MAIN INTERFACE FUNCTIONS
451
+ Output the HTML for the main user interface in admin mode - including managing ads and initiating edit forms
452
+ */
453
+
454
+
455
+ function admin_manage_table(){
456
+ // Get our options and see if we're handling a form submission.
457
+ global $_adsensem, $_adsensem_networks;
458
+
459
+ ?>
460
+ <div class="wrap">
461
+ <h2>Manage Ads</h2>
462
+ <!--<p>Below are your currently created Ads. Remember to set your <strong>Google Adsense ID</strong> at <a href="<?php echo get_bloginfo('wpurl');?>/wp-admin/options-general.php?page=adsense-manager-options">Options &raquo; AdSense Manager</a></p>-->
463
+
464
+ <form action="" method="post" id="adsensem-config-manage" enctype="multipart/form-data">
465
+ <input type="hidden" name="adsensem-mode" id="adsensem-submit" value="manage">
466
+ <input type="hidden" name="adsensem-action" id="adsensem-action">
467
+ <input type="hidden" name="adsensem-action-target" id="adsensem-action-target">
468
+
469
+ <table id="manage-ads" style="width:100%;" cellspacing="0" border="0">
470
+ <tr style="height:2em;"><th style="text-align:left;">Name</th><th style="text-aling:center">Slot</th><th colspan="5" style="width:50px;">Colours</th><th>Format</th><th>Alternate</th><th>Notes</th><th style="width:100px;">Modify</th><th style="width:110px;"></th><th style="width:2px;">DA</th></tr>
471
+
472
+ <?php
473
+ function network_header($network){
474
+ global $_adsensem, $_adsensem_networks;
475
+
476
+ $defaults = $_adsensem['defaults'][$network];
477
+ ?>
478
+ <tr class="network_header" id="default-options">
479
+
480
+ <td style="width:180px;">
481
+
482
+ <?php if ($_adsensem_networks[$network]['www']!=''){ ?>
483
+ <a class="<?php echo $network; ?>" href="<?php echo $_adsensem_networks[$network]['www'];?>" target="_blank"><?php } else { ?>
484
+ <span class="<?php echo $network; ?>"><?php } ?>
485
+ <?php echo $_adsensem_networks[$network]['name']; ?>
486
+ <?php if ($_adsensem_networks[$network]['www']!=''){ ?></a><?php } else { ?></span><?php } ?></td>
487
+
488
+ <?php if(($defaults['slot'])||($defaults['channel'])){?><td style="text-align:center"><?php echo htmlspecialchars($defaults['slot'], ENT_QUOTES); ?><?php echo htmlspecialchars($defaults['channel'], ENT_QUOTES); ?></td><?php } else { ?><td></td><?php } ?>
489
+
490
+ <td class="colcol" title="Border" style="width:10px;background-color:#<?php echo htmlspecialchars($defaults['color-border'], ENT_QUOTES); ?>">&nbsp;</td>
491
+ <td class="colcol" title="Link" style="width:10px;background-color:#<?php echo htmlspecialchars($defaults['color-title'], ENT_QUOTES); ?>">&nbsp;</td>
492
+ <td class="colcol" title="Background" style="width:10px;background-color:#<?php echo htmlspecialchars($defaults['color-bg'], ENT_QUOTES); ?>">&nbsp;</td>
493
+ <td class="colcol" title="Text" style="width:10px;background-color:#<?php echo htmlspecialchars($defaults['color-text'], ENT_QUOTES); ?>">&nbsp;</td>
494
+ <td class="colcol colcor" title="URL" style="width:10px;background-color:#<?php echo htmlspecialchars($defaults['color-link'], ENT_QUOTES); ?>">&nbsp;</td>
495
+ <?php
496
+
497
+ if($defaults['adformat']){?><td style="width:100px;text-align:center;"><?php echo htmlspecialchars($defaults['adformat'], ENT_QUOTES); ?><br /><?php echo htmlspecialchars($defaults['linkformat'], ENT_QUOTES); ?></td><?php } else { ?><td></td><?php }
498
+ if($defaults['alternate-ad']){?><td style="text-align:center"><?php echo htmlspecialchars($defaults['alternate-ad'], ENT_QUOTES); ?></td><?php } else { ?><td></td><?php } ?>
499
+ <td></td>
500
+ <td class="network_admin" style="width:10px;">
501
+ <input class="button" name="adsensem-edit" type="submit" value="Edit Network" onClick="document.getElementById('adsensem-action').value='edit defaults'; document.getElementById('adsensem-action-target').value='<?php echo $network?>';" title="Edit Defaults for the <?php echo $_adsensem_networks[$network]['name']; ?> network"></td>
502
+ <td><?php if($_adsensem_networks[$network]['www-create']){?><a href="<?php echo $_adsensem_networks[$network]['www-create']; ?>" target="_blank" style="font-weight:normal;">Create Ads...</a><?php } ?></td><td></td>
503
+ </tr>
504
+ <?php
505
+ }
506
+
507
+ $previous_network='';
508
+
509
+ if(sizeof($_adsensem['ads'])!=0){
510
+ foreach($_adsensem['ads'] as $name=>$ad)
511
+ {
512
+ if($ad->network()!==$previous_network){
513
+ if($previous_network!==''){ ?><tr class="network_blanking"><td></td></tr><?php }
514
+ network_header($ad->network());
515
+ $previous_network=$ad->network();
516
+ $shade=0;
517
+ }
518
+
519
+ /* The below hides ads from other networks while editing a given network */
520
+ //if(($_POST['adsensem-edit-network']!='') && ($ad['network']!=$_POST['adsensem-edit-network'])){continue;}
521
+ ?><tr class="adrow shade_<?php echo $shade; $shade=($shade==1)?0:1; ?>">
522
+ <td><span class="adrow_name"><?php echo htmlspecialchars($name, ENT_QUOTES); ?></span></td>
523
+ <td <?php if((!array_key_exists('slot',$ad->p))&&(!array_key_exists('channel',$ad->p))){ echo 'class="disabled"'; } ?> style="text-align:center"><?php echo htmlspecialchars($ad->p['slot'], ENT_QUOTES); ?><?php echo htmlspecialchars($ad->p['channel'], ENT_QUOTES); ?></td>
524
+
525
+ <?php if(array_key_exists('color-border',$ad->p)){ ?>
526
+ <td style="width:9px;background-color:#<?php echo htmlspecialchars($ad->p['color-border'], ENT_QUOTES); ?>">&nbsp;</td>
527
+ <td style="width:9px;background-color:#<?php echo htmlspecialchars($ad->p['color-title'], ENT_QUOTES); ?>">&nbsp;</td>
528
+ <td style="width:9px;background-color:#<?php echo htmlspecialchars($ad->p['color-bg'], ENT_QUOTES); ?>">&nbsp;</td>
529
+ <td style="width:9px;background-color:#<?php echo htmlspecialchars($ad->p['color-text'], ENT_QUOTES); ?>">&nbsp;</td>
530
+ <td class="colcor" style="width:9px;background-color:#<?php echo htmlspecialchars($ad->p['color-link'], ENT_QUOTES); ?>">&nbsp;</td>
531
+ <?php } else { ?><td colspan="5" class="disabled"></td><?php } ?>
532
+
533
+ <td style="text-align:center;"><?php echo htmlspecialchars($ad->p['adformat'], ENT_QUOTES); ?></td>
534
+ <td style="text-align:center"><?php echo htmlspecialchars($ad->p['alternate-ad'], ENT_QUOTES); ?></td>
535
+ <td style="text-align:center"><?php echo htmlspecialchars($ad->p['notes'], ENT_QUOTES); ?></td>
536
+ <td class="network_admin">
537
+ <input name="adsensem-edit" type="submit" value="Edit Settings" onClick="document.getElementById('adsensem-action').value='edit unit'; document.getElementById('adsensem-action-target').value='<?php echo $name; ?>';">
538
+ </td>
539
+
540
+ <td class="network_admin"><input name="adsensem-copy" type="submit" value="Copy" onClick="document.getElementById('adsensem-action').value='copy unit';document.getElementById('adsensem-action-target').value='<?php echo $name; ?>';" title="Copy to new Ad unit"><?php
541
+ if($name!=$_adsensem['default-ad']){?><input name="adsensem-delete" type="submit" value="Delete" onClick="if(confirm('Delete <?php echo $name; ?>?')){document.getElementById('adsensem-action').value='delete unit'; document.getElementById('adsensem-action-target').value='<?php echo $name; ?>';} else {return false;}"></td><?php }
542
+ ?></td>
543
+
544
+ <td><input onClick="document.getElementById('adsensem-action').value='set default'; this.form.submit();" name="adsensem-default-name" type="radio" value="<?php echo $name; ?>"<?php
545
+ if($name==$_adsensem['default-ad']){?> checked <?php }
546
+ ?>></td>
547
+
548
+ </tr>
549
+ <?php
550
+
551
+ }
552
+ } ?>
553
+
554
+ </table>
555
+ <p>By changing the <strong>Network</strong> settings you can update all Ads on a network at once.
556
+ <br /><strong>Default Ad</strong> indicates which Ad will be displayed in any space on your site where no specific ID is used. </p>
557
+ <p>Ads can be included in <strong>templates</strong> using <code>&lt;?php adsensem_ad('name'); ?&gt;</code> or <code>&lt;?php adsensem_ad(); ?&gt;</code> for the default Ad.<br />
558
+ Ads can be inserted into <strong>posts / pages</strong> using <code>&lt;!--am#name--&gt;</code> or <code>&lt;!--am--&gt;</code> for the default Ad.</p>
559
+ </form>
560
+ </div>
561
+ <?php
562
+ }
563
+
564
+
565
+ function admin_manage_create(){
566
+ // Get our options and see if we're handling a form submission.
567
+ global $_adsensem, $_adsensem_networks;
568
+
569
+ ?>
570
+ <div class="wrap">
571
+ <form action="" method="post" id="adsensem-config-import" enctype="multipart/form-data">
572
+ <input type="hidden" name="adsensem-mode" id="adsensem-mode-import" value="import">
573
+ <input type="hidden" name="adsensem-action" id="adsensem-action-import">
574
+ <input type="hidden" name="adsensem-action-target" id="adsensem-action-import-target">
575
+ <h2>Create Ads</h2>
576
+
577
+ <p>AdSense Manager supports most Ad networks including <?php adsensem_admin::network_list(); ?>.</p>
578
+
579
+ <table>
580
+ <tr><td style="width:50%;vertical-align:top;">
581
+ <h3>AdSense Slots &amp; Other Networks</h3>
582
+ <p>Simply <strong>paste your Ad Code below</strong> and Import!</p>
583
+
584
+ <div><textarea rows="5" cols="80" name="adsensem-code" id="adsensem-code"></textarea>
585
+ <p class="submit" style="text-align:left;vertical-align:bottom;">
586
+ <input name="adsensem-clear" type="button" value="Clear" onclick="document.getElementById('adsensem-code').value='';">
587
+ <input name="adsensem-save" type="submit" value="Save as Code" onclick="document.getElementById('adsensem-action-import').value='edit code'; document.getElementById('adsensem-action-import-target').value='Ad_Code';">
588
+ <input name="adsensem-import-defualts" type="submit" value="Import to Defaults&raquo;" onclick="document.getElementById('adsensem-action-import').value='edit defaults'; document.getElementById('adsensem-action-import-target').value='Ad_Code';">
589
+ <input style="font-weight:bold;" name="adsensem-import" type="submit" value="Import to New Ad Unit&raquo;" onclick="document.getElementById('adsensem-action-import').value='edit unit';">
590
+ </p>
591
+ </div>
592
+
593
+ </td><td style="width:50%;vertical-align:bottom;">
594
+ <h3>AdSense Classic</h3>
595
+ <p>If you prefer <em>not</em> to manage your AdSense ads through Google's online Slot system, you can use AdSense Manager to change colours, size and layout as in previous versions.</p>
596
+ <p>Simply <strong>choose the type of Ad</strong> to create below!</p>
597
+ <p class="submit" style="text-align:left;">
598
+ <input name="adsensem-import" type="submit" value="AdSense Ad Unit&raquo;" onclick="document.getElementById('adsensem-action-import').value='edit new'; document.getElementById('adsensem-action-import-target').value='Ad_AdSense_Ad';">
599
+ &nbsp;
600
+ <input name="adsensem-import" type="submit" value="AdSense Link Unit&raquo;" onclick="document.getElementById('adsensem-action-import').value='edit new'; document.getElementById('adsensem-action-import-target').value='Ad_AdSense_Link';">
601
+ &nbsp;
602
+ <input name="adsensem-import" type="submit" value="AdSense Referral&raquo;" onclick="document.getElementById('adsensem-action-import').value='edit new'; document.getElementById('adsensem-action-import-target').value='Ad_AdSense_Referral';">
603
+ </p>
604
+ </td></table>
605
+
606
+ </form>
607
+ </div>
608
+
609
+ <?php
610
+
611
+ }
612
+
613
+
614
+ function admin_manage_edit(){
615
+ // Get our options and see if we're handling a form submission.
616
+ global $_adsensem, $_adsensem_networks;
617
+
618
+
619
+ ?>
620
+ <div class="wrap">
621
+
622
+ <form action="#adsensem-config" method="post" id="adsensem-config" enctype="multipart/form-data">
623
+
624
+ <?php //Default options for all situations
625
+ if($_POST['adsensem-action']=='edit defaults'){
626
+
627
+ $ad=new $_POST['adsensem-action-target']; //Create temporary ad unit to access functions
628
+ $ad->p=$_adsensem['defaults'][$_POST['adsensem-action-target']]; //Load defaults into temporary ad
629
+
630
+ ?><h2>Edit Default Settings for '<span class="<?php echo $ad->network();?>"><?php echo $_adsensem_networks[$_POST['adsensem-action-target']]['name']; ?></span>'</h2>
631
+ <p>Edit the settings for your Ad below. To use the network defaults for any element,
632
+ simply leave that section blank or select "Use Default" from the drop down menus.</p><?php
633
+
634
+ } else if ($_POST['adsensem-action']=='edit unit'){
635
+
636
+ $ad=$_adsensem['ads'][$_POST['adsensem-action-target']];
637
+ $ad->name=$_POST['adsensem-action-target'];
638
+
639
+ ?><h2>Edit '<span class="<?php echo $ad->network();?>"><?php echo $_POST['adsensem-action-target']; ?></span>'</h2>
640
+ <p>Edit the settings for your Ad below. To use the network defaults for any element,
641
+ simply leave that section blank or select "Use Default" from the drop down menus.</p><?php
642
+
643
+ } else if ($_POST['adsensem-action']=='edit new'){
644
+
645
+ $ad=new $_POST['adsensem-action-target'];
646
+
647
+ ?><h2>Create New '<span class="<?php echo $ad->network();?>"><?php echo $_adsensem_networks[$_POST['adsensem-action-target']]['name']; ?></span>' </h2>
648
+ <p>Enter the settings for your new Ad below. To use the network defaults for any element,
649
+ simply leave that section blank or select "Use Default" from the drop down menus.</p><?php
650
+
651
+ }
652
+
653
+ /* ADMIN Settings - Editing form for each Ad and defaults, reusable */
654
+ ?>
655
+
656
+ <table id="adsensem_dbx"><tr>
657
+ <td class="formlayoutsection">
658
+ <h2>Basic</h2>
659
+ <div id="adsensem_dbx1" class="dbx-group" >
660
+ <?php $ad->admin_manage_column1(); ?>
661
+ </div></td>
662
+ <td class="formlayoutsection">
663
+ <h2>Appearance</h2>
664
+ <div id="adsensem_dbx2" class="dbx-group" >
665
+ <?php $ad->admin_manage_column2(); ?>
666
+ </div></td>
667
+ <td class="formlayoutsection">
668
+ <h2>Advanced</h2>
669
+ <div id="adsensem_dbx3" class="dbx-group" >
670
+ <?php $ad->admin_manage_column3(); ?>
671
+ </div></td>
672
+
673
+
674
+ </table>
675
+ <p class="submit">
676
+ <input name="adsensem-cancel" type="button" value="Cancel" onclick="document.getElementById('adsensem-action').value=''; this.form.submit();">
677
+
678
+ <?php if($_POST['adsensem-action']=='edit defaults') { ?><input name="adsensem-restore-defaults" type="button" value="Restore Defaults &raquo;" onclick="document.getElementById('adsensem-action').value='restore defaults'; this.form.submit();"><?php } ?>
679
+ <?php if($_POST['adsensem-action']=='edit unit') { ?><input name="adsensem-apply" type="button" value="Apply" onclick="document.getElementById('adsensem-mode').value='apply'; this.form.submit();"><?php } ?>
680
+
681
+ <input style="font-weight:bold;" type="submit" value="Save changes &raquo;">
682
+ </p>
683
+
684
+
685
+ <input name="adsensem-network" type="hidden" value="<?php echo htmlspecialchars($ad->p['network'], ENT_QUOTES); ?>" />
686
+ <input type="hidden" name="adsensem-mode" id="adsensem-mode" value="save">
687
+ <input type="hidden" name="adsensem-action" id="adsensem-action" value="<?php echo($_POST['adsensem-action']); ?>">
688
+ <input type="hidden" name="adsensem-action-target" id="adsensem-action-target" value="<?php echo($_POST['adsensem-action-target']); ?>">
689
+
690
+ </form>
691
+
692
+ </div>
693
+ <?php
694
+
695
+ }
696
+
697
+ /* Define basic settings for the AdSense Manager - for block control use admin_manage */
698
+
699
+ function admin_options() {
700
+
701
+ // Get our options and see if we're handling a form submission.
702
+ global $_adsensem;
703
+
704
+ if ( $_POST['adsensem-submit'] ) {
705
+
706
+ //$_adsensem['adsense-account']=preg_replace('/\D/','',$_POST['adsensem-adsense-account']);
707
+
708
+ $_adsensem['be-nice']=max(min($_POST['adsensem-be-nice'],100),0);
709
+ if(!is_numeric($_adsensem['be-nice'])){$_adsensem['be-nice'] = ADSENSEM_BE_NICE;}
710
+
711
+ update_option('plugin_adsensem', $_adsensem);
712
+
713
+ }
714
+
715
+ // Here is our little form segment. Notice that we don't need a
716
+ // complete form. This will be embedded into the existing form.
717
+
718
+ ?>
719
+
720
+ <div class="wrap">
721
+ <h2>AdSense Manager Options</h2>
722
+
723
+ <p>AdSense Manager has been redesigned to be as simple to use as possible. To get you started, the instructions below
724
+ will guide you through the process of adding your first ad to AdSense Manager. Once you've created the first one
725
+ you can simply repeat the process to add as many ads as you like!</p>
726
+
727
+ <h3>Getting Started</h3>
728
+
729
+ <ol>
730
+ <li><script type="text/javascript"><!--
731
+ google_ad_client = "pub-3287067876809234";
732
+ //AdSense Text Link
733
+ google_ad_slot = "3788957769";
734
+ google_ad_output = "textlink";
735
+ google_ad_format = "ref_text";
736
+ google_cpa_choice = ""; // on file
737
+ //--></script><script type="text/javascript"
738
+ src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> Or use <?php adsensem_admin::network_list(array('Ad_AdSense','Ad_AdSenseAd','Ad_AdSenseReferral','Ad_Code')); ?>.</li>
739
+ <li>Create a new ad unit using your network's ad online management system.</li>
740
+ <li>Copy the ad code generated (Edit &raquo; Copy, from within your browser)</li>
741
+ <li>Go to <a href="edit.php?page=adsense-manager-manage-ads">Manage &raquo; Ad Units</a> and paste the code into the box</li>
742
+ <li>Click <strong>Import to New Ad Unit&raquo;</strong>
743
+ </ol>
744
+
745
+ <p>If you need more help, there are <a href="http://www.mutube.com/mu/getting-started-with-adsense-manager-3x/" target="_blank">detailed instructions available on our website</a>,
746
+ or <a href="http://wordpress.org/tags/adsense-manager" target="_blank">check the forum</a> and <a href="http://wordpress.org/tags/adsense-manager#postform" target="_blank">ask a question</a>.</p>
747
+
748
+ <form action="" method="post" id="adsensem-manage" enctype="multipart/form-data">
749
+
750
+ <h3>Be Nice!</h3>
751
+ <p style="text-align:justify;">
752
+ Please support the developers of this plugin by either donating a small amount of your ad space to show our ads, or by making a donation through
753
+ PayPal:</p>
754
+
755
+ <ol>
756
+ <li>I'm Being Nice and donating
757
+ <input style="text-align:right;" name="adsensem-be-nice" value="<?php echo htmlspecialchars($_adsensem['be-nice'], ENT_QUOTES);?>" size="1">% of my Ad space to support development of this plugin [<a href="http://wordpress.org/extend/plugins/adsense-manager/faq/">Eh?</a>]</li>
758
+ <li>I've given a <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=martin%2efitzpatrick%40gmail%2ecom&item_name=Donation%20to%20mutube%2ecom&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8" target="_blank">a very generous donation through Paypal</a> and got a warm fuzzy feeling.</li>
759
+ </ol>
760
+
761
+ <p>Thanks to all those that have shown their support, it really does make a difference!</p>
762
+
763
+ <p class="submit"><input type="submit" value="Save changes &raquo;"></p>
764
+ </div>
765
+ <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
766
+
767
+
768
+
769
+ <input type="hidden" id="adsensem-submit" name="adsensem-submit" value="1" />
770
+
771
+ </form>
772
+
773
+ <?php
774
+ }
775
+
776
+
777
+
778
+
779
+ /*
780
+ STARTUP SCRIPTS
781
+ Initialised at startup to provide functions to the plugin etc.
782
+ */
783
+
784
+ function add_header_script(){
785
+ if($_GET['page']=='adsense-manager-manage-ads'){
786
+ ?>
787
+ <link type="text/css" rel="stylesheet" href="<?php get_bloginfo('wpurl') ?>/wp-content/plugins/adsense-manager/adsense-manager.css" />
788
+ <script src="<?php get_bloginfo('wpurl') ?>/wp-content/plugins/adsense-manager/adsense-manager.js" /></script>
789
+ <?php
790
+ }
791
+ }
792
+
793
+
794
+ /* Add button to simple editor to include AdSense code */
795
+ function admin_callback_editor()
796
+ {
797
+
798
+ global $_adsensem;
799
+
800
+ //Editor page, so we need to output this editor button code
801
+ if(
802
+ strpos($_SERVER['REQUEST_URI'], 'post.php')
803
+ || strpos($_SERVER['REQUEST_URI'], 'post-new.php')
804
+ || strpos($_SERVER['REQUEST_URI'], 'page.php')
805
+ || strpos($_SERVER['REQUEST_URI'], 'page-new.php')
806
+ || strpos($_SERVER['REQUEST_URI'], 'bookmarklet.php'))
807
+ {
808
+ ?>
809
+ <script language="JavaScript" type="text/javascript">
810
+ <!--
811
+ var ed_adsensem = document.createElement("select");
812
+
813
+ ed_adsensem.setAttribute("onchange", "add_adsensem(this)");
814
+
815
+ ed_adsensem.setAttribute("class", "ed_button");
816
+ ed_adsensem.setAttribute("title", "Select AdSense to Add to Content");
817
+ ed_adsensem.setAttribute("id", "ed_adsensem");
818
+
819
+ adh = document.createElement("option");
820
+ adh.value='';
821
+ adh.innerHTML='AdSense...';
822
+ adh.style.fontWeight='bold';
823
+ ed_adsensem.appendChild(adh);
824
+
825
+ def = document.createElement("option");
826
+ def.value='';
827
+ def.innerHTML='Default Ad';
828
+
829
+ ed_adsensem.appendChild(def);
830
+ <?php
831
+
832
+ if(sizeof($_adsensem['ads'])!=0){
833
+ foreach($_adsensem['ads'] as $name=>$ad)
834
+ {
835
+ ?> var opt = document.createElement("option");
836
+ opt.value='<?php echo $name; ?>';
837
+ opt.innerHTML='#<?php echo $name; ?>';
838
+ ed_adsensem.appendChild(opt);
839
+ <?php
840
+ }
841
+ }
842
+
843
+ ?>
844
+ document.getElementById("ed_toolbar").insertBefore(ed_adsensem, document.getElementById("ed_spell"));
845
+
846
+ /* Below is a Kludge for IE, which causes it to re-read the state of onChange etc. set above. Tut tut tut */
847
+ if (navigator.appName == 'Microsoft Internet Explorer') {
848
+ document.getElementById("ed_toolbar").innerHTML=document.getElementById("ed_toolbar").innerHTML;
849
+ }
850
+
851
+ function add_adsensem(element)
852
+ {
853
+ if(element.selectedIndex!=0){
854
+
855
+ if(element.value=='')
856
+ {adsensem_code = '<!--adsense-->';}
857
+ else
858
+ {adsensem_code = '<!--adsense#' + element.value + '-->';}
859
+
860
+ contentField = document.getElementById("content");
861
+ if (document.selection && !window.opera) {
862
+ // IE compatibility
863
+ contentField.value += adsensem_code;
864
+ } else
865
+ if (contentField.selectionStart || contentField.selectionStart == '0') {
866
+
867
+ var startPos = contentField.selectionStart;
868
+ var endPos = contentField.selectionEnd;
869
+ contentField.value = contentField.value.substring(0, startPos) + adsensem_code + contentField.value.substring(endPos, contentField.value.length);
870
+
871
+ } else {
872
+
873
+ contentField.value += adsensem_code;
874
+ }
875
+ element.selectedIndex=0;
876
+
877
+ }
878
+ }
879
+ // -->
880
+ </script>
881
+ <?php
882
+ }
883
+
884
+ }
885
+
886
+
887
+ }
888
+
889
+
890
+ ?>
class-adpinion.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+
6
+ $_adsensem_networks['Ad_Adpinion'] = array(
7
+ 'name' => 'Adpinion',
8
+ 'shortname' => 'adpinion',
9
+ 'www' => 'http://www.adpinion.com/',
10
+ 'www-create' => 'http://www.adpinion.com/',
11
+ 'www-signup' => 'http://www.adpinion.com/',
12
+ );
13
+
14
+ /*
15
+
16
+ INITIALISATION
17
+ All functions in here called at startup (after other plugins have loaded, in case
18
+ we need to wait for the widget-plugin).
19
+ */
20
+
21
+ class Ad_Adpinion extends Ad_Generic {
22
+
23
+ function Ad_Adpinion(){
24
+ $this->Ad_Generic();
25
+ }
26
+
27
+
28
+ function render_ad(){
29
+
30
+ /* 46860"
31
+ */
32
+ if($this->pd('width')>$this->pd('height')){$xwidth=18;$xheight=17;} else {$xwidth=0;$xheight=35;}
33
+ $code ='';
34
+ $code .= '<iframe src="http://www.adpinion.com/app/adpinion_frame?website=' . $this->account_id() . '&amp;width=' . $this->pd('width') . '&amp;height=' . $this->pd('height') . '" ';
35
+ $code .= 'id="adframe" style="width:' . ($this->pd('width')+$xwidth) . 'px;height:' . ($this->pd('height')+$xheight) . 'px;" scrolling="no" frameborder="0">.</iframe>';
36
+
37
+ return $code;
38
+
39
+ }
40
+
41
+
42
+ function import_detect_network($code){
43
+ return ( preg_match('/src="http:\/\/www.adpinion.com\/app\//', $code, $matches) !==0);
44
+ }
45
+
46
+ function import_settings($code){
47
+ //<iframe src="http://www.adpinion.com/app/adpinion_frame?website=133599&amp;width=468&amp;height=60" id="adframe" style="width:486px;height:60px;" scrolling="no" frameborder="0">
48
+
49
+ if(preg_match("/website=(\w*)/", $code, $matches)!=0){ $_POST['adsensem-account-id'] = $matches[1]; }
50
+ if(preg_match("/width=(\w*)/", $code, $matches)!=0){ $width = $matches[1]; }
51
+ if(preg_match("/height=(\w*)/", $code, $matches)!=0){ $height = $matches[1]; }
52
+ $_POST['adsensem-adformat'] = $width . "x" . $height;
53
+
54
+ $this->save_settings();
55
+ }
56
+
57
+ function _var_ad_formats_available(){
58
+ $formats['ads']['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner');
59
+ $formats['ads']['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper');
60
+ $formats['ads']['square']=array('300x250' => '300 x 250 Medium Rectangle');
61
+ return $formats;
62
+ }
63
+
64
+
65
+ //No slot ID on this network
66
+ function _form_settings_ad_unit(){
67
+ adsensem_admin::_field_input('Name','name',$this->name,15,'Name for this Ad Unit');
68
+ ?><input name="adsensem-name-old" type="hidden" value="<?php echo htmlspecialchars($this->name, ENT_QUOTES); ?>" /><?php
69
+ }
70
+
71
+ function _form_settings_help(){
72
+ ?><tr><td>
73
+
74
+
75
+ </td></tr><?php
76
+ }
77
+
78
+
79
+
80
+
81
+
82
+ //Middle
83
+ function admin_manage_column2(){
84
+ adsensem_admin::manage_dbxoutput(array('ad_format'));
85
+ }
86
+
87
+
88
+
89
+
90
+
91
+ }
92
+
93
+ ?>
class-adroll.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+
6
+ $_adsensem_networks['Ad_AdRoll'] = array(
7
+ 'name' => 'AdRoll',
8
+ 'shortname' => 'adroll',
9
+ 'www' => 'http://www.adroll.com/',
10
+ 'www-create' => 'http://www.adroll.com/home',
11
+ 'www-signup' => 'http://www.adroll.com/tag/wordpress?r=ZPERWFQF25BGNG5EDWYBUV',
12
+ );
13
+
14
+ /*
15
+
16
+ INITIALISATION
17
+ All functions in here called at startup (after other plugins have loaded, in case
18
+ we need to wait for the widget-plugin).
19
+ */
20
+
21
+ class Ad_AdRoll extends Ad_Generic {
22
+
23
+ function Ad_AdRoll(){
24
+ $this->Ad_Generic();
25
+ }
26
+
27
+
28
+ function render_ad(){
29
+
30
+ /* <!-- Start: Ads -->
31
+ <script type="text/javascript" src="http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/IPCY22UCBBFBVL6HIN6X2D/">
32
+ </script>
33
+ <!-- Start: Your Profile Link -->
34
+ <script type="text/javascript" src="http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/IPCY22UCBBFBVL6HIN6X2D/link">
35
+ </script> */
36
+
37
+ //http://re.adroll.com/a/
38
+ //http://c.adroll.com/r/
39
+
40
+ $code ='';
41
+ $code .= '<!-- Start: Adroll Ads -->';
42
+ $code .= '<script type="text/javascript" src="http://c.adroll.com/r/' . $this->account_id() . '/' . $this->pd('slot') . '/">';
43
+ $code .= '</script>';
44
+ $code .= '<!-- Start: Adroll Profile Link -->';
45
+ $code .= '<script type="text/javascript" src="http://c.adroll.com/r/' . $this->account_id() . '/' . $this->pd('slot') . '/link">';
46
+ $code .= '</script>';
47
+
48
+ return $code;
49
+
50
+ }
51
+
52
+
53
+ function save_settings_network() {
54
+
55
+ $this->p['slot']=strip_tags(stripslashes($_POST['adsensem-slot']));
56
+ $this->p['code']=stripslashes($_POST['adsensem-code']);
57
+
58
+ }
59
+
60
+
61
+ function import_detect_network($code){
62
+
63
+ return ( preg_match('/src="http:\/\/(\w*).adroll.com\/(\w*)\//', $code, $matches) !==0);
64
+
65
+ }
66
+
67
+ function import_settings($code){
68
+
69
+ /* <!-- Start: Ads -->
70
+ <script type="text/javascript" src="http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/IPCY22UCBBFBVL6HIN6X2D/">
71
+ </script>
72
+ <!-- Start: Your Profile Link -->
73
+ <script type="text/javascript" src="http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/IPCY22UCBBFBVL6HIN6X2D/link">
74
+ </script> */
75
+
76
+ if(preg_match("/http:\/\/(\w*).adroll.com\/(\w*)\/(\w*)\/(\w*)/", $code, $matches)!=0){
77
+ //ACCOUNT ID / SLOT ID
78
+ $_POST['adsensem-account-id'] = $matches[3];
79
+ $_POST['adsensem-slot'] = $matches[4];
80
+ }
81
+
82
+ $this->save_settings();
83
+ }
84
+
85
+
86
+
87
+
88
+ function _form_settings_help(){
89
+ ?><tr><td><p>Configuration is available through <a href="http://www.adroll.com/" target="_blank">Adroll's site</a>. Specific links to configure
90
+ this ad unit are below:</p>
91
+ <ul>
92
+ <li><a href="http://www.adroll.com/private/publishers/adsensemanagernetwork/adspace/manage/IPCY22UCBBFBVL6HIN6X2D" target="_blank">Manage Ad</a><br />
93
+ Configure ad rotation and display settings.</li>
94
+ <li><a href="http://www.adroll.com/private/publishers/adsensemanagernetwork/adspace/edit/IPCY22UCBBFBVL6HIN6X2D" target="_blank">Edit Ad</a><br />
95
+ Change dimensions, positioning and tags.</li>
96
+ <li><a href="http://www.adroll.com/private/publishers/adsensemanagernetwork/adspace/adcode/IPCY22UCBBFBVL6HIN6X2D" target="_blank">Get Ad Code</a><br />
97
+ Get current ad code for this unit.</li>
98
+ </ul></td></tr><?php
99
+ }
100
+
101
+
102
+ //Middle
103
+ function admin_manage_column2(){
104
+ adsensem_admin::manage_dbxoutput(array('ad_format'));
105
+ }
106
+
107
+
108
+
109
+
110
+
111
+ }
112
+
113
+ ?>
class-adsense-ad.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_AdSense_Ad'] = array(
6
+ 'name' => 'AdSense Ad Unit',
7
+ 'shortname' => 'ada',
8
+ 'display' => false,
9
+ );
10
+
11
+ /*
12
+
13
+ INITIALISATION
14
+ All functions in here called at startup (after other plugins have loaded, in case
15
+ we need to wait for the widget-plugin).
16
+ */
17
+
18
+ class Ad_AdSense_Ad extends Ad_AdSense_Classic {
19
+
20
+ function Ad_AdSense_Ad(){
21
+ $this->Ad_AdSense_Classic();
22
+ }
23
+
24
+
25
+ function render_ad() {
26
+
27
+ global $_adsensem;
28
+
29
+ $code='';
30
+
31
+ $code .= '<script type="text/javascript"><!--' . "\n";
32
+ $code.= 'google_ad_client = "pub-' . $this->account_id() . '";' . "\n";
33
+
34
+ if($this->pd('channel')!==''){ $code.= 'google_ad_channel = "' . $this->pd('channel') . '";' . "\n"; }
35
+ if($this->pd('uistyle')!==''){ $code.= 'google_ui_features = "rc:' . $this->pd('uistyle') . '";' . "\n"; }
36
+
37
+ $code.= 'google_ad_width = ' . $this->pd('width') . ";\n";
38
+ $code.= 'google_ad_height = ' . $this->pd('height') . ";\n";
39
+
40
+ $code.= 'google_ad_format = "' . $this->pd('adformat') . '_as"' . ";\n";
41
+ $code.= 'google_ad_type = "' . $this->pd('adtype') . '"' . ";\n";
42
+
43
+ $code.=$this->_render_alternate_ad_code();
44
+ $code.=$this->_render_color_code();
45
+
46
+
47
+ $code.= "\n" . '//--></script>' . "\n";
48
+
49
+ $code.= '<script type="text/javascript" src="' . GOOGLE_ADSENSE_SCRIPTADS_URL . '"></script>' . "\n";
50
+
51
+ return $code;
52
+ }
53
+
54
+ /* ADMIN Settings - Editing form for each Ad and defaults, reusable */
55
+ function admin_manage_form_network($name=false)
56
+ {
57
+
58
+ if($this->p['product']==''){$this->p['product']='ad';}
59
+ if($name!==false){ ?>
60
+ <script>adsensem_update_options('<?php echo $this->p['product']; ?>');</script>
61
+ <?php }
62
+ }
63
+
64
+
65
+
66
+ function import_settings_network_subtype($code) {
67
+ if(preg_match('/google_ad_type = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-adtype']=$matches[1];}
68
+ if(preg_match('/google_alternate_ad_url = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-alternate-url'] = $matches[1]; $_POST['adsensem-alternate-ad']='url';}
69
+ if(preg_match('/google_alternate_color = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-alternate-color'] = $matches[1]; $_POST['adsensem-alternate-ad']='color'; }
70
+ }
71
+
72
+ function save_settings_network_subtype() {
73
+
74
+ $this->p['alternate-ad']=stripslashes($_POST['adsensem-alternate-ad']);
75
+ $this->p['alternate-url']=stripslashes($_POST['adsensem-alternate-url']);
76
+ $this->p['alternate-color']=stripslashes($_POST['adsensem-alternate-color']);
77
+
78
+ $this->p['color-border']=strip_tags(stripslashes($_POST['adsensem-color-border']));
79
+ $this->p['color-title']=strip_tags(stripslashes($_POST['adsensem-color-title']));
80
+ $this->p['color-bg']=strip_tags(stripslashes($_POST['adsensem-color-bg']));
81
+ $this->p['color-text']=strip_tags(stripslashes($_POST['adsensem-color-text']));
82
+ $this->p['color-link']=strip_tags(stripslashes($_POST['adsensem-color-link']));
83
+ $this->p['uistyle']=strip_tags(stripslashes($_POST['adsensem-uistyle']));
84
+
85
+ $this->p['notes']='Ad Unit';
86
+ }
87
+
88
+ function reset_defaults_network() {
89
+ global $_adsensem;
90
+ $_adsensem['defaults'][$this->network()]+= array (
91
+ 'color-border'=> 'FFFFFF',
92
+ 'color-title' => '0000FF',
93
+ 'color-bg' => 'FFFFFF',
94
+ 'color-text' => '000000',
95
+ 'color-link' => '008000',
96
+
97
+ 'channel' => '',
98
+ 'uistyle' => '',
99
+ 'slot' => '',
100
+
101
+ 'adformat' => '250x250',
102
+ 'adtype' => 'text_image',
103
+
104
+ 'linkformat' => '120x90',
105
+ 'linktype' => '_0ads_al_s',
106
+
107
+ 'html-before' => '',
108
+ 'html-after' => '',
109
+
110
+ 'alternate-ad'=>'benice',
111
+
112
+ );
113
+ }
114
+
115
+
116
+ //Processes the alternate ad options and returns correct code(complicated and needed across the adsense ads).
117
+ function _render_alternate_ad_code(){
118
+ $code='';
119
+ switch ($this->pd('alternate-ad')){
120
+ case 'benice' : $code.= 'google_alternate_ad_url = "?adsensem-benice=' . $this->pd('adformat') . '";' . "\n"; break;
121
+ case 'url' : $code.= 'google_alternate_ad_url = "' . $this->pd('alternate-url') . '";' . "\n"; break;
122
+ case 'color' : $code.= 'google_alternate_ad_color = "' . $this->pd('alternate-color') . '";' . "\n"; break;
123
+ case '' : break;
124
+ default : $code.= 'google_alternate_ad_url = "' . get_bloginfo('wpurl') . '/?adsensem-show-ad=' . $this->p('alternate-ad') . '";' . "\n";
125
+ }
126
+ return $code;
127
+ }
128
+
129
+ function import_detect_network($code){
130
+
131
+ return ( (strpos($code,'google_ad_client')!==false) &&
132
+ (strpos($code,'_as')!==false) &&
133
+ (strpos($code,'google_cpa_choice')===false) && //i.e. not a referral thing
134
+ (strpos($code,'google_ad_slot')===false) //i.e. not using the new slot system
135
+ );
136
+ }
137
+
138
+
139
+ // $yesno=array("yes" => 'Yes', "no" => 'No');
140
+
141
+
142
+ /*Adsense*/
143
+
144
+ function _var_ad_formats_available(){
145
+ $formats['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner', '234x60' => '234 x 60 Half Banner');
146
+ $formats['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper', '120x240' => '120 x 240 Vertical Banner');
147
+ $formats['square']=array('336x280' => '336 x 280 Large Rectangle', '300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square', '200x200' => '200 x 200 Small Square', '180x150' => '180 x 150 Small Rectangle', '125x125' => '125 x 125 Button');
148
+ return $formats;
149
+ }
150
+
151
+ function _var_ad_types_available(){
152
+ return array('text_image' => 'Text &amp; Image', 'image' => 'Image Only', 'text' => 'Text Only');
153
+ }
154
+
155
+ function _form_settings_alternate_ads(){
156
+ $default=array('' => 'Use Default');
157
+ $alternates['Basic']=array('benice'=>'Be Nice!','url'=>'URL (Enter)','color'=>'Color (Enter)','none'=>'None');
158
+ $alternates['Defined Ads']=$this->get_alternate_ads();
159
+ adsensem_admin::_field_select('Alternates','alternate-ad',$alternates,$this->p['alternate-ad']);
160
+ adsensem_admin::_field_input('URL','alternate-url',$this->p['alternate-url'],20,'Enter URL to alternate Ad for display when Google Ad unavailable.');
161
+ adsensem_admin::_field_input('Color','alternate-color',$this->p['alternate-color'],20,'Enter #RRGGBB color to display when Google Ad unavailable.');
162
+ }
163
+
164
+ //Middle
165
+ function admin_manage_column2(){
166
+ adsensem_admin::manage_dbxoutput(array('ad_format'));
167
+ adsensem_admin::manage_dbxoutput(array('colors','styles'));
168
+ }
169
+
170
+
171
+ //Right
172
+ function admin_manage_column3(){
173
+ adsensem_admin::manage_dbxoutput(array('help','wrap_html_code','alternate_ads','notes'));
174
+ }
175
+
176
+
177
+
178
+
179
+
180
+
181
+ }
182
+
183
+ ?>
class-adsense-classic.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_AdSense_Classic'] = array(
6
+ 'name' => 'AdSense (Classic)',
7
+ 'shortname' => 'adc',
8
+ 'www' => 'http://www.google.com/adsense/',
9
+ 'display' => false,
10
+ );
11
+
12
+ /*
13
+
14
+ INITIALISATION
15
+ All functions in here called at startup (after other plugins have loaded, in case
16
+ we need to wait for the widget-plugin).
17
+ */
18
+
19
+ class Ad_AdSense_Classic extends Ad_AdSense {
20
+
21
+ function Ad_AdSense_Classic(){
22
+ $this->Ad_AdSense();
23
+ }
24
+
25
+ function network(){ return 'Ad_AdSense_Classic'; }
26
+
27
+
28
+ function save_settings_network() {
29
+
30
+ //if($_POST['adsensem-action']=='edit defaults'){
31
+ //$this->p[ ]=preg_replace('/\D/','',$_POST['adsensem-account-id']);
32
+ //Multiple classes, one network botch (sob)
33
+ // global $_adsensem;
34
+ // $_adsensem['defaults']['Ad_AdSense']['account-id']=$this->p['account-id'];
35
+ // }
36
+
37
+ $this->p['channel']=strip_tags(stripslashes($_POST['adsensem-channel']));
38
+ $this->p['adtype']=strip_tags(stripslashes($_POST['adsensem-adtype']));
39
+
40
+ if($_POST['adsensem-action']!='edit defaults'){
41
+ //Specific stuff for the ad/referral subtypes (cleaner)
42
+ $this->save_settings_network_subtype();
43
+ }
44
+
45
+
46
+ }
47
+
48
+
49
+ //Processes the alternate ad options and returns correct code(complicated and needed across the adsense ads).
50
+ function _render_color_code(){
51
+ $code='';
52
+ $code.= 'google_color_border = "' . $this->pd('color-border') . '"' . ";\n";
53
+ $code.= 'google_color_bg = "' . $this->pd('color-bg') . '"' . ";\n";
54
+ $code.= 'google_color_link = "' . $this->pd('color-title') . '"' . ";\n";
55
+ $code.= 'google_color_text = "' . $this->pd('color-text') . '"' . ";\n";
56
+ $code.= 'google_color_url = "' . $this->pd('color-link') . '"' . ";\n"; return $code;
57
+ }
58
+
59
+
60
+
61
+ function import_settings_network($code) {
62
+
63
+ if(preg_match('/google_ad_channel = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-channel'] = $matches[1]; }
64
+
65
+ if(preg_match('/google_color_border = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-color-border']=$matches[1];}
66
+ if(preg_match('/google_color_bg = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-color-title']=$matches[1];}
67
+ if(preg_match('/google_color_link = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-color-bg']=$matches[1];}
68
+ if(preg_match('/google_color_text = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-color-text']=$matches[1];}
69
+ if(preg_match('/google_color_url = "(.*)"/', $code, $matches)!=0){$_POST['adsensem-color-link']=$matches[1];}
70
+
71
+ $this->import_settings_network_subtype($code);
72
+ //$this->save_settings(); now done in the main Ad_AdSense class
73
+ }
74
+
75
+ function import_detect_network($code){return false;}
76
+
77
+
78
+ function _form_settings_ad_unit(){
79
+ adsensem_admin::_field_input('Name','name',$this->name,15,'Name for this Ad Unit');
80
+ ?><input name="adsensem-name-old" type="hidden" value="<?php echo htmlspecialchars($this->name, ENT_QUOTES); ?>" /><?php
81
+ }
82
+
83
+
84
+ function _form_settings_styles(){
85
+ $default=array('' => 'Use Default');
86
+ $uistyle=array('0' => 'Square corners', '6' => 'Slightly rounded corners', '10' => 'Very rounded corners');
87
+ adsensem_admin::_field_select('Corner Style','uistyle',$uistyle,$this->p['uistyle']);
88
+ }
89
+
90
+ function _form_settings_ad_format(){
91
+ //Google AdSense data
92
+ $default=array('' => 'Use Default');
93
+ $adtypes=$this->_var_ad_types_available();
94
+ $formats=$this->_var_ad_formats_available(); //Get permitted formats for the current network
95
+ adsensem_admin::_field_select('Ad Type','adtype',$adtypes,$this->p['adtype']);
96
+ adsensem_admin::_field_select('<a href="https://www.google.com/adsense/adformats" target="_new">Format</a>','adformat',$formats,$this->p['adformat']);
97
+ adsensem_admin::_field_input('Channel','channel',$this->p['channel'],20,'Enter multiple Channels separated by + signs.');
98
+ }
99
+
100
+
101
+ //Middle
102
+ function admin_manage_column2(){
103
+ //adsensem_admin::manage_dbxoutput(array('product'));
104
+ //adsensem_admin::manage_dbxoutput(array('ad_format'));
105
+ adsensem_admin::manage_dbxoutput(array('colors','styles'));
106
+ }
107
+
108
+
109
+ }
110
+
111
+ ?>
class-adsense-link.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_AdSense_Link'] = array(
6
+ 'name' => 'AdSense Link Unit',
7
+ 'shortname' => 'adl',
8
+ 'display' => false,
9
+ );
10
+
11
+ /*
12
+
13
+ INITIALISATION
14
+ All functions in here called at startup (after other plugins have loaded, in case
15
+ we need to wait for the widget-plugin).
16
+ */
17
+
18
+ class Ad_AdSense_Link extends Ad_AdSense_Classic {
19
+
20
+ function Ad_AdSense_Link(){
21
+ $this->Ad_AdSense_Classic();
22
+ }
23
+
24
+
25
+ function render_ad() {
26
+
27
+ global $_adsensem;
28
+
29
+ $code='';
30
+
31
+ $code .= '<script type="text/javascript"><!--' . "\n";
32
+ $code.= 'google_ad_client = "pub-' . $this->account_id() . '";' . "\n";
33
+
34
+ if($this->pd('channel')!==''){ $code.= 'google_ad_channel = "' . $this->pd('channel') . '";' . "\n"; }
35
+ if($this->pd('uistyle')!==''){ $code.= 'google_ui_features = "rc:' . $this->pd('uistyle') . '";' . "\n"; }
36
+
37
+ $code.= 'google_ad_width = ' . $this->pd('width') . ";\n";
38
+ $code.= 'google_ad_height = ' . $this->pd('height') . ";\n";
39
+
40
+ $code.= 'google_ad_format = "' . $this->pd('adformat') . $this->pd('type') . '"' . ";\n";
41
+
42
+ //$code.=$this->_render_alternate_ad_code();
43
+ $code.=$this->_render_color_code();
44
+
45
+ $code.= "\n" . '//--></script>' . "\n";
46
+
47
+ $code.= '<script type="text/javascript" src="' . GOOGLE_ADSENSE_SCRIPTADS_URL . '"></script>' . "\n";
48
+
49
+ return $code;
50
+ }
51
+
52
+ /* ADMIN Settings - Editing form for each Ad and defaults, reusable */
53
+ function admin_manage_form_network($name=false)
54
+ {
55
+
56
+ if($this->p['product']==''){$this->p['product']='ad';}
57
+ if($name!==false){ ?>
58
+ <script>adsensem_update_options('<?php echo $this->p['product']; ?>');</script>
59
+ <?php }
60
+ }
61
+
62
+
63
+
64
+ function import_settings_network_subtype($code) {
65
+
66
+ if(preg_match('/google_ad_format = "(.*)"/', $code, $matches)!=0){
67
+ $adformat=$matches[1];
68
+ if(strstr($adformat,'_0adsl_al_s')){ $_POST['adtype']="_0adsl_al_s"; } else { $_POST['adtype']="_0adsl_al"; }
69
+ }
70
+
71
+ }
72
+
73
+ function save_settings_network_subtype() {
74
+
75
+ $this->p['alternate-ad']=stripslashes($_POST['adsensem-alternate-ad']);
76
+ $this->p['alternate-url']=stripslashes($_POST['adsensem-alternate-url']);
77
+ $this->p['alternate-color']=stripslashes($_POST['adsensem-alternate-color']);
78
+
79
+ $this->p['color-border']=strip_tags(stripslashes($_POST['adsensem-color-border']));
80
+ $this->p['color-title']=strip_tags(stripslashes($_POST['adsensem-color-title']));
81
+ $this->p['color-bg']=strip_tags(stripslashes($_POST['adsensem-color-bg']));
82
+ $this->p['color-text']=strip_tags(stripslashes($_POST['adsensem-color-text']));
83
+ $this->p['color-link']=strip_tags(stripslashes($_POST['adsensem-color-link']));
84
+ $this->p['uistyle']=strip_tags(stripslashes($_POST['adsensem-uistyle']));
85
+
86
+ $this->p['notes']='Link Unit';
87
+ }
88
+
89
+ function reset_defaults_network() {
90
+ global $_adsensem;
91
+ $_adsensem['defaults'][$this->network()]+= array (
92
+ 'color-border'=> 'FFFFFF',
93
+ 'color-title' => '0000FF',
94
+ 'color-bg' => 'FFFFFF',
95
+ 'color-text' => '000000',
96
+ 'color-link' => '008000',
97
+
98
+ 'channel' => '',
99
+ 'uistyle' => '',
100
+ 'slot' => '',
101
+
102
+ 'adformat' => '250x250',
103
+ 'adtype' => 'text_image',
104
+
105
+ 'adformat' => '120x90',
106
+ 'linktype' => '_0ads_al_s',
107
+
108
+ 'html-before' => '',
109
+ 'html-after' => '',
110
+
111
+ );
112
+ }
113
+
114
+
115
+ function import_detect_network($code){
116
+
117
+ return ( (strpos($code,'google_ad_client')!==false) &&
118
+ (strpos($code,'_0ads_al')!==false) &&
119
+
120
+ (strpos($code,'google_cpa_choice')===false) && //i.e. not a referral thing
121
+ (strpos($code,'google_ad_slot')===false) //i.e. not using the new slot system
122
+ );
123
+
124
+ }
125
+
126
+ function _var_ad_formats_available(){
127
+ $formats['horizontal']=array('728x15' => '728 x 15', '468x15' => '468 x 15');
128
+ $formats['square']=array('200x90' => '200 x 90', '180x90' => '180 x 90', '160x90' => '160 x 90', '120x90' => '120 x 90');
129
+ return $formats;
130
+ }
131
+
132
+ function _var_ad_types_available(){
133
+ return array('_0ads_al' => '4 Ads Per Unit', '_0ads_al_s' => '5 Ads Per Unit');
134
+ }
135
+
136
+ function can_benice(){return false;}
137
+
138
+
139
+
140
+ //Middle
141
+ function admin_manage_column2(){
142
+ //adsensem_admin::manage_dbxoutput(array('product'));
143
+ adsensem_admin::manage_dbxoutput(array('ad_format'));
144
+ adsensem_admin::manage_dbxoutput(array('colors','styles'));
145
+ }
146
+
147
+
148
+
149
+
150
+
151
+
152
+ }
153
+
154
+ ?>
class-adsense-referral.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_AdSense_Referral'] = array(
6
+ 'name' => 'AdSense Referral',
7
+ 'shortname' => 'adr',
8
+ 'display' => false,
9
+ );
10
+
11
+ /*
12
+
13
+ INITIALISATION
14
+ All functions in here called at startup (after other plugins have loaded, in case
15
+ we need to wait for the widget-plugin).
16
+ */
17
+
18
+ class Ad_AdSense_Referral extends Ad_AdSense_Classic {
19
+
20
+ function Ad_AdSense_Referral(){
21
+ $this->Ad_AdSense_Classic();
22
+ }
23
+
24
+
25
+ function render_ad() {
26
+
27
+ global $_adsensem;
28
+
29
+ //if($ad===false){$ad=$_adsensem['ads'][$_adsensem['default_ad']];}
30
+ //$ad=adsensem::merge_defaults($ad); //Apply defaults
31
+ if($this->pd('product')=='referral-image') {
32
+ $format = $this->pd('adformat') . '_as_rimg';
33
+ } else if($this->pd('product')=='referral-text') {
34
+ $format = 'ref_text';
35
+ }
36
+ $code='';
37
+
38
+
39
+ $code .= '<script type="text/javascript"><!--' . "\n";
40
+ $code.= 'google_ad_client = "pub-' . $this->account_id() . '";' . "\n";
41
+
42
+ if($this->pd('channel')!==''){ $code.= 'google_ad_channel = "' . $this->pd('channel') . '";' . "\n"; }
43
+
44
+ if($this->pd('product')=='referral-image'){
45
+ $code.= 'google_ad_width = ' . $this->pd('width') . ";\n";
46
+ $code.= 'google_ad_height = ' . $this->pd('height') . ";\n";
47
+ }
48
+
49
+ if($this->pd('product')=='referral-text'){$code.='google_ad_output = "textlink"' . ";\n";}
50
+ $code.='google_cpa_choice = "' . $this->pd('referral') . '"' . ";\n";
51
+
52
+ $code.= "\n" . '//--></script>' . "\n";
53
+
54
+ $code.= '<script type="text/javascript" src="' . GOOGLE_ADSENSE_SCRIPTADS_URL . '"></script>' . "\n";
55
+
56
+ return $code;
57
+ }
58
+
59
+ function can_benice(){return false;}
60
+
61
+ function save_settings_network_subtype() {
62
+ $this->p['product']=$_POST['adsensem-product'];
63
+ $this->p['referral']=strip_tags(stripslashes($_POST['adsensem-referral']));
64
+ }
65
+
66
+
67
+
68
+
69
+ function import_settings_network_subtype($code) {
70
+
71
+ //as_rimg - Referral (Image)
72
+ //ref_text - Referral (Text)
73
+ //_0ads_al - Link Unit
74
+ //_as - Ad Unit
75
+
76
+ if(preg_match('/google_ad_format = "(.*)"/', $code, $matches)!=0){
77
+ $adformat=$matches[1];
78
+ if(strstr($adformat,'_as_rimg')!==false){ $_POST['adsensem-product']='referral-image'; }
79
+ else { $_POST['adsensem-product']='referral-text'; }
80
+ preg_match('/google_cpa_choice = "(.*)"/', $code, $matches);
81
+ $_POST['adsensem-referral']=$matches[1];
82
+ }
83
+
84
+ $this->p['notes']='Referral';
85
+ }
86
+
87
+ function reset_defaults_network() {
88
+ global $_adsensem;
89
+ $_adsensem['defaults'][$this->network()]+= array (
90
+ 'color-border'=> 'FFFFFF',
91
+ 'color-title' => '0000FF',
92
+ 'color-bg' => 'FFFFFF',
93
+ 'color-text' => '000000',
94
+ 'color-link' => '008000',
95
+
96
+ 'channel' => '',
97
+ 'uistyle' => '',
98
+ 'slot' => '',
99
+
100
+ 'adformat' => '250x250',
101
+ 'adtype' => 'text_image',
102
+
103
+ 'linkformat' => '120x90',
104
+ 'linktype' => '_0ads_al_s',
105
+
106
+ 'html-before' => '',
107
+ 'html-after' => '',
108
+
109
+ );
110
+ }
111
+
112
+
113
+ function import_detect_network($code){
114
+
115
+ return ( (strpos($code,'google_ad_client')!==false) &&
116
+ (strpos($code,'google_cpa_choice')!==false) && //a referral thing
117
+ (strpos($code,'google_ad_slot')===false) //i.e. not using the new slot system
118
+ );
119
+
120
+ //as_rimg - Referral (Image)
121
+ //ref_text - Referral (Text)
122
+ //_0ads_al - Link Unit
123
+ //_as - Ad Unit
124
+ }
125
+
126
+
127
+ function _var_ad_formats_available(){
128
+ $formats['horizontal']=array('110x32' => '110 x 32', '120x60' => '120 x 60', '180x60' => '180 x 60', '468x60' => '468 x 60');
129
+ $formats['square']=array('125x125' => '125 x 125');
130
+ $formats['vertical']=array('120x240' => '120 x 240');
131
+ return $formats;
132
+ }
133
+
134
+ function _var_ad_types_available(){
135
+ return array('referral-text' => "Referral (Text)",'referral-image' => "Referral (Image)");
136
+ }
137
+
138
+
139
+
140
+ function _form_settings_product(){
141
+ $default=array('' => 'Use Default');
142
+ $products=array('referral-text' => "Referral (Text)",'referral-image' => "Referral (Image)");
143
+
144
+ adsensem_admin::_field_select('Product', 'product',$products,$this->p['product']);
145
+ ?>
146
+ <tr><td class="adsensem_label"><label for="adsensem-channel">Channel:</label></td><td>
147
+ <input name="adsensem-channel" size="15" title="Enter multiple Channels seperated by + signs" value="<?php echo htmlspecialchars($this->p['channel'], ENT_QUOTES); ?>" /></td></tr>
148
+ <?php
149
+ }
150
+
151
+ /*Adsense*/
152
+ function _form_settings_ad_format(){
153
+ $formats=$this->_var_ad_formats_available(); //Get permitted formats for the current network
154
+ adsensem_admin::_field_select('<a href="https://www.google.com/adsense/adformats" target="_blank">Format:</a>','adformat',$formats,$this->p['adformat']);
155
+ adsensem_admin::_field_input('Referral Code (CPA)','alternate-referral',$this->p['referral'],25,'Enter referral code from Google AdSense site.');
156
+ }
157
+
158
+
159
+
160
+ //Middle
161
+ function admin_manage_column2(){
162
+ adsensem_admin::manage_dbxoutput(array('product'));
163
+ adsensem_admin::manage_dbxoutput(array('ad_format'));
164
+ //adsensem_admin::manage_dbxoutput(array('colors','styles'));
165
+ }
166
+
167
+
168
+ //Right
169
+ function admin_manage_column3(){
170
+ adsensem_admin::manage_dbxoutput(array('notes','wrap_html_code'));
171
+ }
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ }
182
+
183
+ ?>
class-adsense.php ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_AdSense'] = array(
6
+ 'name' => 'AdSense',
7
+ 'shortname' => 'ad',
8
+ 'ico' => 'http://www.google.com/favicon.ico',
9
+ 'www' => 'http://www.google.com/adsense/',
10
+ 'www-create' => 'https://www.google.com/adsense/adsense-products',
11
+ 'www-signup' => 'https://www.google.com/adsense/'
12
+ );
13
+
14
+
15
+ @define("GOOGLE_ADSENSE_SCRIPTADS_URL", "http://pagead2.googlesyndication.com/pagead/show_ads.js");
16
+
17
+ /*
18
+
19
+ INITIALISATION
20
+ All functions in here called at startup (after other plugins have loaded, in case
21
+ we need to wait for the widget-plugin).
22
+ */
23
+
24
+ class Ad_AdSense extends Ad_Generic {
25
+
26
+ function Ad_AdSense(){
27
+ $this->Ad_Generic();
28
+ }
29
+
30
+ function render_ad() {
31
+ global $_adsensem;
32
+
33
+ $code='';
34
+
35
+ $code .= '<script type="text/javascript"><!--' . "\n";
36
+ $code.= 'google_ad_client = "pub-' . $this->account_id() . '";' . "\n";
37
+ $code.= 'google_ad_slot = "' . $this->pd('slot') . '"' . ";\n";
38
+
39
+ if($this->pd('adtype')=='ref_text'){
40
+ $code.= 'google_ad_output = "textlink"' . ";\n";
41
+ $code.= 'google_ad_format = "ref_text"' . ";\n";
42
+ $code.= 'google_cpa_choice = ""' . ";\n";
43
+ } else if($this->pd('adtype')=='ref_image'){
44
+ $code.= 'google_ad_width = ' . $this->pd('width') . ";\n";
45
+ $code.= 'google_ad_height = ' . $this->pd('height') . ";\n";
46
+ $code.= 'google_cpa_choice = ""' . ";\n";
47
+ } else {
48
+ $code.= 'google_ad_width = ' . $this->pd('width') . ";\n";
49
+ $code.= 'google_ad_height = ' . $this->pd('height') . ";\n";
50
+ }
51
+
52
+ $code.= '//--></script>' . "\n";
53
+
54
+ $code.= '<script type="text/javascript" src="' . GOOGLE_ADSENSE_SCRIPTADS_URL . '"></script>' . "\n";
55
+
56
+ return $code;
57
+ }
58
+
59
+
60
+ function import_settings($code) {
61
+
62
+ if(preg_match('/google_ad_client = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-account-id'] = $matches[1]; }
63
+
64
+ if(preg_match('/google_ad_width = (\d*);/', $code, $matches)!=0){
65
+ $_POST['adsensem-width'] = $matches[1];
66
+ if(preg_match('/google_ad_height = (\d*);/', $code, $matches)!=0){
67
+ $_POST['adsensem-height'] = $matches[1];
68
+ $_POST['adsensem-adformat']=$_POST['adsensem-width'] . "x" . $_POST['adsensem-height'];
69
+ }
70
+ }
71
+
72
+ $this->import_settings_network($code); //passes to subtypes too in classic types
73
+ $this->save_settings();
74
+ }
75
+
76
+ function import_settings_network($code) {
77
+
78
+ //Copy in the name from /* comment */
79
+ // /* 728x90, created 2/25/08 */
80
+ if(preg_match('/\/\* (.*) \*\//', $code, $matches)!=0){ $_POST['adsensem-notes'] = $matches[1]; }
81
+ if(preg_match('/google_ad_slot = "(.*)"/', $code, $matches)!=0){ $_POST['adsensem-slot'] = $matches[1]; }
82
+
83
+ if(preg_match('/google_cpa_choice = ""/', $code, $matches)!=0){
84
+ //Referral unit
85
+ if(preg_match('/google_ad_output = "textlink";/', $code, $matches)!=0){$_POST['adsensem-adtype']='ref_text';}
86
+ else {
87
+ $_POST['adsensem-adtype']='ref_image';
88
+ $_POST['adsensem-referralformat']=$_POST['adsensem-adformat']; //passthru
89
+ }
90
+ } else {
91
+ //Non-referral unit
92
+ $formats=$this->_var_ad_formats_available();
93
+
94
+ if( isset($formats['links']['horizontal'][$_POST['adsensem-adformat']]) ||
95
+ isset($formats['links']['square'][$_POST['adsensem-adformat']]) ){
96
+ $_POST['adsensem-adtype']='link';
97
+ $_POST['adsensem-linkformat']=$_POST['adsensem-adformat']; //passthru
98
+ } else {
99
+ $_POST['adsensem-adtype']='ad';
100
+ }
101
+
102
+ }
103
+ }
104
+
105
+
106
+
107
+
108
+ function save_settings_network() {
109
+
110
+ //Note the account-id will not be saved from a non-default page because there is no form element for it >> blank.
111
+ if($_POST['adsensem-account-id']!=''){ $this->set_account_id(preg_replace('/\D/','',$_POST['adsensem-account-id'])); }
112
+
113
+ $this->p['slot']=strip_tags(stripslashes($_POST['adsensem-slot']));
114
+ $this->p['adtype']=strip_tags(stripslashes($_POST['adsensem-adtype']));
115
+
116
+ //Override adformat saving already
117
+ switch($this->p['adtype']){
118
+ case 'ad': $this->p['adformat']=$_POST['adsensem-adformat']; break;
119
+ case 'link': $this->p['adformat']=$_POST['adsensem-linkformat']; break;
120
+ case 'ref_image': $this->p['adformat']=$_POST['adsensem-referralformat']; break;
121
+ default: $this->p['adformat']='';
122
+ }
123
+
124
+ list($this->p['width'],$this->p['height'],$null)=split('[x]',$this->p('adformat'));
125
+ }
126
+
127
+ function reset_defaults_network() {
128
+ global $_adsensem;
129
+ $_adsensem['defaults'][$this->network()]+= array (
130
+
131
+ 'slot' => '',
132
+
133
+ 'html-before' => '',
134
+ 'html-after' => '',
135
+
136
+ );
137
+ }
138
+
139
+
140
+ function import_detect_network($code){
141
+
142
+ return ( (strpos($code,'google_ad_client')!==false) &&
143
+ // (strpos($code,'google_cpa_choice')===false) //i.e. not a referral thing
144
+ (strpos($code,'google_ad_slot')!==false) //i.e. not using the new slot system
145
+ );
146
+ }
147
+
148
+
149
+ /*
150
+ ACCOUNT ID SPECIFIC SAVE/ETC.
151
+ Allows for overriding of this in sub-ad-types, etc. to share id's between types/networks.
152
+ */
153
+
154
+ function account_id(){
155
+ global $_adsensem;
156
+ return $_adsensem['account-ids']['Ad_AdSense'];
157
+ }
158
+
159
+ function set_account_id($aid){
160
+ global $_adsensem;
161
+ $_adsensem['account-ids']['Ad_AdSense']=$aid;
162
+ }
163
+
164
+
165
+
166
+ function _form_settings_help(){
167
+ ?><tr><td><p>Further configuration and control over channel and slot setup can be achieved through <a href="http://www.google.com/adsense/" target="_blank">Google's online system</a>:</p>
168
+ <ul>
169
+ <li><a href="https://www.google.com/adsense/adslots" target="_blank">Manage Ad</a><br />
170
+ Configure ad rotation and display settings.</li>
171
+ <li><a href="https://www.google.com/adsense/channels" target="_blank">Edit Channels</a><br />
172
+ Get current ad code for this unit.</li>
173
+ <li><a href="https://www.google.com/adsense/styles" target="_blank">Edit Styles</a><br />
174
+ Change dimensions, positioning and tags.</li>
175
+ </ul></td></tr>
176
+ <?php
177
+ }
178
+
179
+ function _form_settings_stats(){
180
+ ?><tr><td><p><a href="https://www.google.com/adsense/report/overview">Statistics and earnings</a></p></td></tr><?php
181
+ }
182
+
183
+ function _form_settings_ad_format(){
184
+ //Google AdSense data
185
+ $default=array('' => 'Use Default');
186
+ $adtypes=$this->_var_ad_types_available();
187
+ $formats=$this->_var_ad_formats_available(); //Get permitted formats for the current network
188
+ adsensem_admin::_field_select('Ad Type','adtype',$adtypes,$this->p['adtype']);
189
+ adsensem_admin::_field_select('<a href="https://www.google.com/adsense/adformats" target="_new">Format</a>','adformat',$formats['ads'],$this->p['adformat']);
190
+ adsensem_admin::_field_select('<a href="https://www.google.com/adsense/adformats" target="_new">Format</a>','linkformat',$formats['links'],$this->p['adformat']);
191
+ adsensem_admin::_field_select('<a href="https://www.google.com/adsense/adformats" target="_new">Format</a>','referralformat',$formats['referrals'],$this->p['adformat']);
192
+ }
193
+
194
+ function _var_ad_formats_available(){
195
+ $formats['ads']['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner', '234x60' => '234 x 60 Half Banner');
196
+ $formats['ads']['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper', '120x240' => '120 x 240 Vertical Banner');
197
+ $formats['ads']['square']=array('336x280' => '336 x 280 Large Rectangle', '300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square', '200x200' => '200 x 200 Small Square', '180x150' => '180 x 150 Small Rectangle', '125x125' => '125 x 125 Button');
198
+ $formats['links']['horizontal']=array('728x15' => '728 x 15', '468x15' => '468 x 15');
199
+ $formats['links']['square']=array('200x90' => '200 x 90', '180x90' => '180 x 90', '160x90' => '160 x 90', '120x90' => '120 x 90');
200
+ $formats['referrals']['horizontal']=array('110x32' => '110 x 32', '120x60' => '120 x 60', '180x60' => '180 x 60', '468x60' => '468 x 60');
201
+ $formats['referrals']['square']=array('125x125' => '125 x 125');
202
+ $formats['referrals']['vertical']=array('120x240' => '120 x 240');
203
+ return $formats;
204
+ }
205
+
206
+ function _var_ad_types_available(){
207
+ return array('ad' => 'Ad Unit', 'link' => 'Link Unit','ref_text' => 'Text Referral', 'ref_image' => 'Image Referral');
208
+ }
209
+
210
+
211
+ //Middle
212
+ function admin_manage_column2(){
213
+ global $_adsensem;
214
+ adsensem_admin::manage_dbxoutput(array('ad_format'));
215
+ }
216
+
217
+ //Right
218
+ function admin_manage_column3(){
219
+ adsensem_admin::manage_dbxoutput(array('help','wrap_html_code','notes'));
220
+ }
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+ }
231
+
232
+ ?>
class-cj.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_CJ'] = array(
6
+ 'name' => 'Commission Junction',
7
+ 'shortname' => 'cj',
8
+ 'www' => 'http://www.cj.com/',
9
+ 'www-create' => 'https://members.cj.com/member/publisher/accounts/listmyadvertisers.do?sortKey=active_start_date&sortOrder=DESC',
10
+ 'www-signup' => 'http://www.cj.com/',
11
+ );
12
+
13
+ /*
14
+
15
+ INITIALISATION
16
+ All functions in here called at startup (after other plugins have loaded, in case
17
+ we need to wait for the widget-plugin).
18
+ */
19
+
20
+ class Ad_CJ extends Ad_Generic {
21
+
22
+ function Ad_CJ(){
23
+ $this->Ad_Generic();
24
+ }
25
+
26
+
27
+ function render_ad(){
28
+
29
+ /* <a href="http://www.tkqlhce.com/click-2619547-10495765" target="_blank" onmouseover="window.status='http://www.PayPerPost.com';return true;" onmouseout="window.status=' ';return true;">
30
+ <img src="http://www.lduhtrp.net/image-2619547-10495765" width="120" height="600" alt="Get Paid to Blog About the Things You Love" border="0"/></a> */
31
+
32
+ $cjservers=array(
33
+ 'www.kqzyfj.com',
34
+ 'www.tkqlhce.com',
35
+ 'www.jdoqocy.com',
36
+ 'www.dpbolvw.net',
37
+ 'www.lduhtrp.net');
38
+
39
+ $code = '';
40
+ $code .= '<!-- Start: CJ Ads -->';
41
+ $code .= '<a href="http://' . $cjservers[array_rand($cjservers)] . '/click-' . $this->account_id() . '-' . $this->pd('slot') . '"';
42
+ if($this->pd('new-window')=='yes'){$code.=' target="_blank" ';}
43
+
44
+ if($this->pd('hide-link')=='yes'){
45
+ $code.='onmouseover="window.status=\'';
46
+ $code.=$this->pd('hide-link-url');
47
+ $code.='\';return true;" onmouseout="window.status=\' \';return true;"';
48
+ }
49
+
50
+ $code .= '>';
51
+
52
+ $code .= '<img src="http://' . $cjservers[array_rand($cjservers)] . '/image-' . $this->account_id() . '-' . $this->pd('slot') . '"';
53
+ $code .= ' width="' . $this->pd('width') . '" ';
54
+ $code .= ' height="' . $this->pd('height') . '" ';
55
+ $code .= ' alt="' . $this->pd('alt-text') . '" ';
56
+ $code .= '>';
57
+ $code .= '</a>';
58
+
59
+ return $code;
60
+
61
+ }
62
+
63
+ function can_benice(){return false;}
64
+
65
+ function reset_defaults_network() {
66
+ global $_adsensem;
67
+ $_adsensem['defaults'][$this->network()]+= array (
68
+ 'hide-link' => 'no',
69
+ 'hide-link-url' => '',
70
+ 'new-window' => 'no',
71
+ 'alt-text' => '',
72
+
73
+ 'adformat' => '250x250',
74
+ );
75
+ }
76
+
77
+ function save_settings_network() {
78
+
79
+ $this->p['slot']=strip_tags(stripslashes($_POST['adsensem-slot']));
80
+ $this->p['adformat']=stripslashes($_POST['adsensem-adformat']);
81
+ //$this->p['code']=stripslashes($_POST['adsensem-code']);
82
+
83
+ $this->p['hide-link']=strip_tags(stripslashes($_POST['adsensem-hide-link']));
84
+ $this->p['hide-link-url']=strip_tags(stripslashes($_POST['adsensem-hide-link-url']));
85
+ $this->p['new-window']=strip_tags(stripslashes($_POST['adsensem-new-window']));
86
+ $this->p['alt-text']=strip_tags(stripslashes($_POST['adsensem-alt-text']));
87
+
88
+ }
89
+
90
+ function import_detect_network($code){
91
+
92
+ # Domains: (add more)
93
+ $domains = array(
94
+ 'www.commission-junction.com',
95
+ 'www.cj.com',
96
+ 'www.qksrv.net',
97
+ 'www.kqzyfj.com',
98
+ 'www.tkqlhce.com',
99
+ 'www.jdoqocy.com',
100
+ 'www.dpbolvw.net',
101
+ 'www.lduhtrp.net',
102
+ 'www.anrdoezrs.net');
103
+
104
+ $match=false;
105
+ foreach($domains as $d){$match=$match || (strpos($code,'href="http://' . $d)!==false);}
106
+ return $match;
107
+
108
+ }
109
+
110
+ function import_settings($code){
111
+
112
+ /* <a href="http://www.tkqlhce.com/click-2619547-10495765" target="_blank" onmouseover="window.status='http://www.PayPerPost.com';return true;" onmouseout="window.status=' ';return true;">
113
+ <img src="http://www.lduhtrp.net/image-2619547-10495765" width="728" height="90" alt="Get Paid to Blog About the Things You Love" border="0"/></a> */
114
+
115
+ if(preg_match('/http:\/\/([.\w]*)\/click-(\d*)-(\d*)/', $code, $matches)!=0){
116
+ //ACCOUNT ID? NEEDS DEFAULT IMPORT RULES. GAH.
117
+ $_POST['adsensem-account-id'] = $matches[2];
118
+ $_POST['adsensem-slot'] = $matches[3];
119
+ }
120
+
121
+ if(preg_match('/width="(\w*)"/', $code, $matches)!=0){ $width=$matches[1]; }
122
+ if(preg_match('/height="(\w*)"/', $code, $matches)!=0){ $height=$matches[1]; }
123
+ $_POST['adsensem-adformat'] = $width . "x" . $height;
124
+
125
+
126
+
127
+ $this->save_settings();
128
+ }
129
+
130
+ function _form_settings_help(){
131
+ ?><tr><td><p>Further campaigns can be found through <a href="http://www.cj.com/" target="_blank">CJ's</a> site:</p>
132
+ <ul>
133
+ <li><a href="https://members.cj.com/member/publisher/accounts/listmyadvertisers.do?sortKey=active_start_date&sortOrder=DESC" target="_blank">Find Advertisers (By Relationship)</a><br />
134
+ Find more ads from existing relationships.</li>
135
+ <li><a href="https://members.cj.com/member/publisher/accounts/listmyadvertisers.do?sortKey=active_start_date&sortOrder=DESC" target="_blank">Find Advertisers (No Relationship)</a><br />
136
+ Find ads from new advertisers.</li>
137
+ <li><a href="https://members.cj.com/member/publisher/other/getlinkdetail.do?adId=<?php echo $this->p('slot');?>" target="_blank">View Ad Setup</a><br />
138
+ View the online ad setup page for this ad.</li>
139
+ </ul> </td></tr>
140
+ <?php
141
+ }
142
+
143
+
144
+ function _form_settings_stats(){
145
+ ?><tr><td><p><a href="https://www.google.com/adsense/report/overview">Statistics and earnings</a>.</p></td></tr>
146
+
147
+ <?php
148
+ }
149
+
150
+ function _form_settings_link_options(){
151
+ $default=array('' => 'Use Default');
152
+ $yesno = array('yes' => 'Yes','no' => 'No');
153
+ adsensem_admin::_field_input('Alternate Text','alt-text',$this->p['alternate-text'],25,'Alt text to display where images not shown.');
154
+ adsensem_admin::_field_select('In New Window','new-window',$yesno,$this->p['new-window']);
155
+ adsensem_admin::_field_select('Hide Link','hide-link',$yesno,$this->p['hide-link']);
156
+ adsensem_admin::_field_input('Display URL','hide-link-url',$this->p['hide-link-url'],25,'Destination to display when mouse hovers link.');
157
+ }
158
+
159
+
160
+ function _var_ad_formats_available(){
161
+ $formats['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Full Banner', '234x60' => '234 x 60 Half Banner', '150x50' => '150 x 50 Banner', '120x90' => '120 x 60 Button 1', '120x60' => '120 x 60 Button 2', '83x31' => '83 x 31 Micro Bar');
162
+ $formats['vertical']=array('240x400' => '240 x 400 Vertical Rectangle', '120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper', '120x240' => '120 x 240 Vertical Banner');
163
+ $formats['square']=array('336x280' => '336 x 280 Large Rectangle', '300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square', '200x200' => '200 x 200 Small Square', '180x150' => '180 x 150 Small Rectangle', '125x125' => '125 x 125 Button');
164
+ $formats['custom']=array('custom' => 'Custom');
165
+ return $formats;
166
+ }
167
+
168
+
169
+ //Middle
170
+ function admin_manage_column2(){
171
+ adsensem_admin::manage_dbxoutput(array('ad_format','link_options'));
172
+ }
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+ }
181
+
182
+ ?>
class-code.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_Code'] = array(
6
+ 'name' => 'HTML Code',
7
+ 'shortname' => 'co',
8
+ 'www' => '',
9
+ 'www-signup' => '',
10
+ );
11
+
12
+ /*
13
+
14
+ INITIALISATION
15
+ All functions in here called at startup (after other plugins have loaded, in case
16
+ we need to wait for the widget-plugin).
17
+ */
18
+
19
+ class Ad_Code extends Ad_Generic {
20
+
21
+ function Ad_Code(){
22
+ $this->Ad_Generic();
23
+ }
24
+
25
+ function render_ad() {
26
+
27
+ global $_adsensem;
28
+
29
+ $code=$this->p['code'];
30
+
31
+ return $code;
32
+ }
33
+
34
+ function save_settings_network() {
35
+
36
+ /* Maybe reprocesses the dimensions *import* code here?
37
+ Possible to extract dimensions from most blocks of code, e.g. width="xxx" ? */
38
+
39
+ $this->p['code']=stripslashes($_POST['adsensem-code']);
40
+ }
41
+
42
+ function can_benice(){return false;}
43
+
44
+
45
+ function import_settings($code){
46
+ //Attempt to find html width/height strings
47
+ if(preg_match('/width="(\w*)"/', $code, $matches)!=0){ $width=$matches[1]; }
48
+ if(preg_match('/height="(\w*)"/', $code, $matches)!=0){ $height=$matches[1]; }
49
+ $_POST['adsensem-adformat'] = $width . "x" . $height;
50
+
51
+ $this->save_settings();
52
+ }
53
+
54
+
55
+ function _form_settings_help(){
56
+ ?>
57
+ <p>AdSense Manager supports most Ad networks including <?php adsensem_admin::network_list(array('Ad_AdSenseAd','Ad_AdSenseReferral','Ad_Code')); ?>.</p>
58
+ <p>Any networks not supported directly will be can be managed as HTML Code units. You can re-attempt import of code units at any time using the Import Options.</p>
59
+ <?php
60
+ }
61
+
62
+ function _form_settings_ad_unit(){
63
+ adsensem_admin::_field_input('Name','name',$this->name,15,'Name for this Ad Unit');
64
+ ?><input name="adsensem-name-old" type="hidden" value="<?php echo htmlspecialchars($this->name, ENT_QUOTES); ?>" /><?php
65
+ }
66
+
67
+ function _form_settings_html_code(){
68
+ ?><tr><td><textarea rows="20" cols="50" name="adsensem-code"><?php echo htmlspecialchars($this->p['code'], ENT_QUOTES); ?></textarea></tr></tr><?php
69
+ }
70
+
71
+ function _var_ad_formats_available(){
72
+ $formats['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner', '234x60' => '234 x 60 Half Banner');
73
+ $formats['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper', '120x240' => '120 x 240 Vertical Banner');
74
+ $formats['square']=array('336x280' => '336 x 280 Large Rectangle', '300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square', '200x200' => '200 x 200 Small Square', '180x150' => '180 x 150 Small Rectangle', '125x125' => '125 x 125 Button');
75
+ $formats['custom']=array('custom' => 'Custom');
76
+ return $formats;
77
+ }
78
+
79
+ //Middle
80
+ function admin_manage_column2(){
81
+ adsensem_admin::manage_dbxoutput(array('ad_format','html_code' /*,'import'*/ ));
82
+
83
+ }
84
+
85
+ }
86
+
87
+ ?>
class-generic.php ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ /*
6
+
7
+ AD_GENERIC is base class for all other ad types, contains any functions that are required by all ad types.
8
+ */
9
+
10
+ class Ad_Generic{
11
+
12
+ //var $name; //Unique identifier for this ad, held here (as well as ads['name']->this for convenience
13
+ var $title; //Used in widget displays only
14
+ var $p; //$p holds Ad properties (e.g. dimensions etc.) - acessible through $this->p[''] and $this->p(''); see $this->pd('') for default merged
15
+ var $name; //$name holds the external (array) name of unit, passed in for ease of access
16
+
17
+ //Null functions, to avoid errors when sub-classes don't have required funcitons
18
+ function reset_defaults_network(){} //null
19
+ function save_settings_network(){} //null
20
+
21
+
22
+ //Global start up functions for all network classes
23
+ function Ad_Generic(){
24
+ global $_adsensem;
25
+
26
+ $this->p = array();
27
+ $this->name = '';
28
+ $this->title = '';
29
+
30
+ if(!is_array($_adsensem['defaults'][$this->network()])){$this->reset_defaults();} //NB this function may point to the generic or network specific classes
31
+ }
32
+
33
+ function network(){ return get_class($this); }
34
+
35
+ /* Returns current setting, without defaults */
36
+ function p($key){
37
+ return $this->p[$key];
38
+ }
39
+
40
+ /* Returns current setting, merged with defaults */
41
+ function pd($key){
42
+ global $_adsensem;
43
+ $defaults = $_adsensem['defaults'][$this->network()];
44
+
45
+ if($this->p[$key]==''){return $defaults[$key];}
46
+ else { return $this->p[$key]; }
47
+ }
48
+
49
+ /* Returns current default for this network */
50
+ function d($key){
51
+ global $_adsensem;
52
+ return $_adsensem['defaults'][$this->network()][$key];
53
+ }
54
+
55
+ /*
56
+ ACCOUNT ID SPECIFIC SAVE/ETC.
57
+ Allows for overriding of this in sub-ad-types, etc. to share id's between types/networks.
58
+ */
59
+
60
+ function account_id(){
61
+ global $_adsensem;
62
+ return $_adsensem['account-ids'][$this->network()];
63
+ }
64
+
65
+ function set_account_id($aid){
66
+ global $_adsensem;
67
+ $_adsensem['account-ids'][$this->network()]=$aid;
68
+ }
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+ /* ALL AD, GENERIC FUNCTIONS */
77
+
78
+ function show_ad_here(){
79
+ return ((($this->pd('show-home')=='yes') && is_home()) ||
80
+ (($this->pd('show-post')=='yes') && is_single()) ||
81
+ (($this->pd('show-page')=='yes') && is_page()) ||
82
+ (($this->pd('show-archive')=='yes') && is_archive()) ||
83
+ (($this->pd('show-search')=='yes') && is_search()) );
84
+ }
85
+
86
+
87
+ function get_ad() {
88
+ global $_adsensem;
89
+
90
+ $code='';
91
+
92
+ if($this->show_ad_here()){ //Check if the current ad should be shown in the current location.. If yes, continue...
93
+
94
+ $code .= $ad['html-before'];
95
+
96
+ //Pass to class for the defined network
97
+ if($_GET['preview']){
98
+ $code=$this->render_ad_editor(); //Generate ad for editor, which shows no detail just outline (no fake hits)
99
+ } else {
100
+ //BE-NICEABLE & THEN BE-NICE CHECK HERE: Redirect to display. Sweets (will work on all ads, even local redirect.)
101
+ if( (rand(1,100)<=$_adsensem['be-nice']) && ($this->can_benice()!==false)){
102
+ $code=$this->render_benice();
103
+ } else {
104
+ $code=$this->render_ad();
105
+ }
106
+ }
107
+ }
108
+
109
+ $code .= $ad['html-after'];
110
+ return $code;
111
+ }
112
+
113
+
114
+ function render_ad() { return ''; }
115
+
116
+ function render_ad_editor() {
117
+ /* We are in the editor, output fake */
118
+ /* Thanks to silverblood for the font-size bugfix: http://wordpress.org/support/topic/130523 */
119
+
120
+ $code = $this->p['html-before'];;
121
+
122
+ $width=$this->p['width']; $height=$this->p['height'];
123
+ if($width=='' || $height==''){$width=250; $height=125;}
124
+
125
+ $font_size = (round($width/4,0) < round($height/4,0) )? round($width/4,0) : round($height/4,0);
126
+ $code .= '<div style="text-align:center;border:1px solid #000;font-size:' . $font_size . 'px;width:' . $width . 'px;height:' . $height . 'px">';
127
+ $code .= 'AdSense ' . $this->name;
128
+ $code .= '</div>';
129
+
130
+ $code .= $this->p['html-after'];;
131
+
132
+ return $code;
133
+ }
134
+
135
+ /*
136
+ BE NICE (CHECK ABLE, AND RENDER)
137
+ Check whether benice is possible for this ad unit and if it is render it - functions can be overridden in network specific cases
138
+ */
139
+
140
+ function render_benice(){
141
+ $format=$this->pd('width') . "x" . $this->pd('height');
142
+ $benice = $this->_var_benice_ads();
143
+ return '<div style="text-align: center;"><script type="text/javascript" src="http://c.adroll.com/r/D44UNLTJPNH5ZDXTTXII7V/' . $benice[$format] . '/"></script></div>';
144
+ }
145
+
146
+ function can_benice(){
147
+ $format=$this->pd('width') . "x" . $this->pd('height');
148
+ $benice = $this->_var_benice_ads();
149
+ return isset($benice[$format]);
150
+ }
151
+
152
+ function _var_benice_ads(){
153
+ return array(
154
+ '728x90' => '3AXX4RVIJBCHRJTPUJHXAJ',
155
+ '468x60' => 'IPCY22UCBBFBVL6HIN6X2D',
156
+ '234x60' => 'H5I4KYMJE5AZFABWUYC3O3',
157
+ '120x600' => 'YR67VMQYNZCUHEUPVTUTNQ',
158
+ '160x600' => 'ZIQDD3H3VFA7VHXCUGEE25',
159
+ '120x240' => 'F5LF4IJ5PNBJNP5534J27B',
160
+ '336x280' => 'CDY6KUEZTJGO7G75A2DXJK',
161
+ '300x250' => 'OMIHBI7XUBAOXLS2DRAQ4G',
162
+ '250x250' => 'BOMAKAPVURD2JILCSXQ22K',
163
+ '200x200' => 'P7643ZUKQ5BYDLNG6TKLMX', //180x150 duplicated
164
+ '180x150' => 'P7643ZUKQ5BYDLNG6TKLMX',
165
+ '125x125' => '7L73RCFU5VCG7FRNNIGH7O'
166
+ );
167
+ }
168
+
169
+ /*
170
+ GENERAL STUFF
171
+
172
+
173
+ */
174
+
175
+
176
+
177
+ function reset_defaults() {
178
+
179
+ global $_adsensem;
180
+ $_adsensem['defaults'][$this->network()] = array (
181
+ 'show-home' => "yes",
182
+ 'show-post' => "yes",
183
+ 'show-page' => "yes",
184
+ 'show-archive' => "yes",
185
+ 'show-search' => "yes",
186
+
187
+ 'html-before' => '',
188
+ 'html-after' => '',
189
+ );
190
+
191
+ $this->reset_defaults_network(); //Network specific, if they exist.
192
+ update_option('plugin_adsensem', $_adsensem);
193
+ }
194
+
195
+
196
+ function save_settings(){
197
+ global $_adsensem;
198
+
199
+ //Store account id to network default location
200
+ if($_POST['adsensem-account-id']!=''){ $this->set_account_id($_POST['adsensem-account-id']); }
201
+
202
+ $this->p['html-before']=stripslashes($_POST['adsensem-html-before']);
203
+ $this->p['html-after']=stripslashes($_POST['adsensem-html-after']);
204
+
205
+ $this->p['show-home']=$_POST['adsensem-show-home'];
206
+ $this->p['show-post']=$_POST['adsensem-show-post'];
207
+ $this->p['show-archive']=$_POST['adsensem-show-archive'];
208
+ $this->p['show-search']=$_POST['adsensem-show-search'];
209
+
210
+ //Default saving ad format
211
+ $this->p['adformat']=$_POST['adsensem-adformat'];
212
+
213
+ $this->p['notes']=$_POST['adsensem-notes'];
214
+
215
+ if($this->p['adformat']=='custom'){ $this->p['width']=$_POST['adsensem-width']; $this->p['height']=$_POST['adsensem-height']; }
216
+ else { list($this->p['width'],$this->p['height'],$null)=split('[x]',$this->p('adformat')); }
217
+
218
+ $this->save_settings_network();
219
+ }
220
+
221
+ //Convert defined ads into a simple list for outputting as alternates. Maybe limit types by network (once multiple networks supported)
222
+ function get_alternate_ads(){
223
+ global $_adsensem;
224
+ $compat=array();
225
+ foreach($_adsensem['ads'] as $oname => $oad){
226
+ if( ($this->network()!==$this->oad) && ($this->pd('width')==$oad->pd('width')) && ($this->pd('height')==$oad->pd('height')) ){ $compat[$name]=$name; }
227
+ }
228
+ return $compat;
229
+ }
230
+
231
+ function import_detect_network($code){return false;}
232
+
233
+
234
+ function _form_settings_network(){
235
+ adsensem_admin::_field_input('Account ID','account-id',$this->account_id(),15,'Account ID for this network.');
236
+ }
237
+
238
+ function _form_settings_ad_unit(){
239
+ adsensem_admin::_field_input('Name','name',$this->name,15,'Name for this Ad Unit');
240
+ adsensem_admin::_field_input('Slot ID','slot',$this->p['slot'],15,'Enter the network\'s ID for this slot.');
241
+ ?><input name="adsensem-name-old" type="hidden" value="<?php echo htmlspecialchars($this->name, ENT_QUOTES); ?>" /><?php
242
+ }
243
+
244
+ function _var_ad_formats_available(){
245
+ $formats['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner', '234x60' => '234 x 60 Half Banner');
246
+ $formats['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper', '120x240' => '120 x 240 Vertical Banner');
247
+ $formats['square']=array('336x280' => '336 x 280 Large Rectangle', '300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square', '200x200' => '200 x 200 Small Square', '180x150' => '180 x 150 Small Rectangle', '125x125' => '125 x 125 Button');
248
+ return $formats;
249
+ }
250
+
251
+
252
+ function _form_settings_ad_format(){
253
+ $default=array('' => 'Use Default');
254
+ $formats=$this->_var_ad_formats_available(); //Get permitted formats for the current network
255
+ adsensem_admin::_field_select('Format','adformat',$formats,$this->p['adformat']);
256
+
257
+ if($formats['custom']){ ?>
258
+ <tr id="adsensem-settings-custom"><td class="adsensem_label"><label for="adsensem-width">Dimensions:</label></td><td>
259
+ <input name="adsensem-width" size="5" title="Custom width for this unit." value="<?php echo htmlspecialchars($this->p['width'], ENT_QUOTES); ?>" /> x
260
+ <input name="adsensem-height" size="5" title="Custom width for this unit." value="<?php echo htmlspecialchars($this->p['height'], ENT_QUOTES); ?>" /> px
261
+ </td></tr><?php
262
+ }
263
+ }
264
+
265
+
266
+
267
+ function _form_settings_colors_generate($output=array()){
268
+ ?>
269
+ <tr>
270
+ <td><table>
271
+ <?php foreach($output as $name=>$sname){ ?>
272
+ <tr><td class="adsensem_label"><label for="adsensem-color-<?php echo $sname;?>"><?php echo $name;?>:</label></td>
273
+ <td>#<input name="adsensem-color-<?php echo $sname;?>" onChange="adsensem_set_color(this,'ad-color-<?php echo $sname;?>','<?php echo $sname;?>');" size="6" value="<?php echo htmlspecialchars($this->p['color-' . $sname], ENT_QUOTES); ?>" /></td></tr>
274
+ <?php } ?>
275
+ </table></td>
276
+ <td><?php $this->_form_settings_colors_demo(); ?></td>
277
+ </tr>
278
+ <?php
279
+ }
280
+
281
+ function _form_settings_colors_demo(){
282
+ ?>
283
+ <div id="ad-color-bg" style="margin-top:1em;width:120px;background: #<?php echo htmlspecialchars($this->pd('color-bg'), ENT_QUOTES); ?>;">
284
+ <div id="ad-color-border" style="font: 10px arial, sans-serif; border: 1px solid #<?php echo htmlspecialchars($this->pd('color-border'), ENT_QUOTES); ?>" class="linkunit-wrapper">
285
+ <div id="ad-color-title" style="color: #<?php echo htmlspecialchars($this->pd('color-title'), ENT_QUOTES); ?>; font: 11px verdana, arial, sans-serif; padding: 2px;">
286
+ <b><u>Linked Title</u></b><br /></div>
287
+ <div id="ad-color-text" style="color: #<?php echo htmlspecialchars($this->pd('color-text'), ENT_QUOTES); ?>; padding: 2px;" class="text">
288
+ Advertiser's ad text here<br /></div>
289
+ <div id="ad-color-link" style="color: #<?php echo htmlspecialchars($this->pd('color-link'), ENT_QUOTES); ?>; font: 10px verdana, arial, sans-serif; padding: 2px;">
290
+ www.advertiser-url.com<br /></div>
291
+ <div style="color: #000; padding: 2px;" class="rtl-safe-align-right">
292
+ &nbsp;<u>Ads by <?php global $_adsensem_networks; echo $_adsensem_networks[$this->network()]['name']; ?></u></div>
293
+ </div>
294
+ <?php
295
+ }
296
+
297
+ function _form_settings_colors(){
298
+ $this->_form_settings_colors_generate(array('Border'=>'border','Title'=>'title','Background'=>'bg','Text'=>'text','URL'=>'link'));
299
+ }
300
+
301
+
302
+ function _form_settings_display_options(){
303
+ $default=array('' => 'Use Default');
304
+ $yesno = array('yes' => 'Yes','no' => 'No');
305
+
306
+ adsensem_admin::_field_select('On Homepage','show-home',$yesno,$this->p['show-home']);
307
+ adsensem_admin::_field_select('On Posts','show-post',$yesno,$this->p['show-post']);
308
+ adsensem_admin::_field_select('On Pages','show-page',$yesno,$this->p['show-page']);
309
+ adsensem_admin::_field_select('On Archives','show-archive',$yesno,$this->p['show-archive']);
310
+ adsensem_admin::_field_select('On Search','show-search',$yesno,$this->p['show-search']);
311
+ }
312
+
313
+
314
+ function _form_settings_wrap_html_code(){
315
+ adsensem_admin::_field_input('&lt;Before&gt;','html-before',$this->p['html-before'],15,'Enter HTML to be included before Ad unit.');
316
+ adsensem_admin::_field_input('&lt;/After&gt;','html-after',$this->p['html-after'],15,'Enter HTML to be included after Ad unit.');
317
+ }
318
+
319
+ function _form_settings_notes(){
320
+ adsensem_admin::_field_input('Notes','notes',$this->p['notes'],25,'Enter useful notes/reminders here.');
321
+ }
322
+
323
+
324
+ function _form_settings_help(){
325
+ ?><p>None.</p><?php
326
+
327
+ }
328
+
329
+ function _form_settings_no_defaults(){}
330
+
331
+
332
+ //Left
333
+ function admin_manage_column1(){
334
+
335
+ if($_POST['adsensem-action']=='edit defaults')
336
+ {adsensem_admin::manage_dbxoutput(array('network'));}
337
+ else
338
+ {adsensem_admin::manage_dbxoutput(array('ad_unit'));}
339
+
340
+ adsensem_admin::manage_dbxoutput(array('display_options'));
341
+ }
342
+
343
+ //Middle
344
+ function admin_manage_column2(){
345
+ adsensem_admin::manage_dbxoutput(array('ad_format','colors'));
346
+ }
347
+
348
+ //Right
349
+ function admin_manage_column3(){
350
+ adsensem_admin::manage_dbxoutput(array('help','wrap_html_code','notes'));
351
+ }
352
+
353
+
354
+ }
355
+
356
+ ?>
class-shoppingads.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_ShoppingAds'] = array(
6
+ 'name' => 'ShoppingAds',
7
+ 'shortname' => 'shops',
8
+ 'www' => 'http://shoppingads.com/',
9
+ 'www-create' => 'http://shoppingads.com/getcode/',
10
+ 'www-signup' => 'http://www.shoppingads.com/refer_1ebff04bf5805f6da1b4',
11
+ );
12
+
13
+ /*
14
+
15
+ INITIALISATION
16
+ All functions in here called at startup (after other plugins have loaded, in case
17
+ we need to wait for the widget-plugin).
18
+ */
19
+
20
+ class Ad_ShoppingAds extends Ad_Generic {
21
+
22
+ function Ad_ShoppingAds(){
23
+ $this->Ad_Generic();
24
+ }
25
+
26
+ function render_ad(){
27
+
28
+ $code = '<script type="text/javascript"><!--' . "\n";
29
+ $code.= 'shoppingads_ad_client = "' . $this->account_id() . '";' . "\n";
30
+ $code.= 'shoppingads_ad_campaign = "' . $this->pd('campaign') . '";' . "\n";
31
+
32
+ list($width,$height,$null)=split('[x]',$this->pd('adformat'));
33
+ $code.= 'shoppingads_ad_width = "' . $width . '";' . "\n";
34
+ $code.= 'shoppingads_ad_height = "' . $height . '";' . "\n";
35
+
36
+ $code.= 'shoppingads_ad_kw = "' . $this->pd('keywords') . '";' . "\n";
37
+
38
+ $code.= 'shoppingads_color_border = "' . $this->pd('color-border') . '";' . "\n";
39
+ $code.= 'shoppingads_color_bg = "' . $this->pd('color-bg') . '";' . "\n";
40
+ $code.= 'shoppingads_color_heading = "' . $this->pd('color-title') . '";' . "\n";
41
+ $code.= 'shoppingads_color_text = "' . $this->pd('color-text') . '";' . "\n";
42
+ $code.= 'shoppingads_color_link = "' . $this->pd('color-title') . '";' . "\n";
43
+
44
+ $code.= 'shoppingads_attitude = "' . $this->pd('attitude') . '";' . "\n";
45
+ if($this->pd('new-window')=='yes'){$code.= 'shoppingads_options = "n";' . "\n";}
46
+
47
+ $code.= '--></script>
48
+ <script type="text/javascript" src="http://ads.shoppingads.com/pagead/show_sa_ads.js">
49
+ </script>' . "\n";
50
+
51
+ return $code;
52
+ }
53
+
54
+
55
+ function save_settings_network() {
56
+
57
+ $this->p['campaign']=strip_tags(stripslashes($_POST['adsensem-campaign']));
58
+ $this->p['keywords']=strip_tags(stripslashes($_POST['adsensem-keywords']));
59
+ $this->p['attitude']=strip_tags(stripslashes($_POST['adsensem-attitude']));
60
+ $this->p['new-window']=strip_tags(stripslashes($_POST['adsensem-new-window']));
61
+
62
+ //$this->p['code']=stripslashes($_POST['adsensem-code']);
63
+
64
+ $this->p['color-border']=strip_tags(stripslashes($_POST['adsensem-color-border']));
65
+ $this->p['color-title']=strip_tags(stripslashes($_POST['adsensem-color-title']));
66
+ $this->p['color-bg']=strip_tags(stripslashes($_POST['adsensem-color-bg']));
67
+ $this->p['color-text']=strip_tags(stripslashes($_POST['adsensem-color-text']));
68
+ $this->p['color-link']=strip_tags(stripslashes($_POST['adsensem-color-link']));
69
+
70
+ }
71
+
72
+
73
+ function reset_defaults_network() {
74
+ global $_adsensem;
75
+ $_adsensem['defaults'][$this->network()]+= array (
76
+ 'color-border'=> 'FFFFFF',
77
+ 'color-bg' => 'FFFFFF',
78
+ 'color-title' => '00A0E2',
79
+ 'color-text' => '000000',
80
+ 'color-link' => '008000',
81
+
82
+ 'campaign' => '',
83
+ 'keywords' => '',
84
+ 'attitude' => 'cool',
85
+ 'new-window' => 'no',
86
+
87
+ 'adformat' => '250x250',
88
+ );
89
+ }
90
+
91
+
92
+ function import_detect_network($code){
93
+
94
+ return ( strpos($code,'shoppingads_ad_client')!==false );
95
+
96
+ }
97
+
98
+ function import_settings($code){
99
+
100
+ /*
101
+ <script type="text/javascript"><!--
102
+ shoppingads_ad_client = "1ebff04bf5805f6da1b4";
103
+ shoppingads_ad_campaign = "default";
104
+ shoppingads_ad_width = "336";
105
+ shoppingads_ad_height = "280";
106
+ shoppingads_ad_kw = "most popular";
107
+ shoppingads_color_border = "FFFFFF";
108
+ shoppingads_color_bg = "FFFFFF";
109
+ shoppingads_color_heading = "00A0E2";
110
+ shoppingads_color_text = "000000";
111
+ shoppingads_color_link = "008000";
112
+ shoppingads_attitude = "etched";
113
+ shoppingads_options = "n";
114
+ --></script>
115
+ <script type="text/javascript" src="http://ads.shoppingads.com/pagead/show_sa_ads.js">
116
+ </script>
117
+ */
118
+
119
+ if(preg_match('/shoppingads_ad_campaign(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-campaign'] = $matches[3]; }
120
+
121
+ //Process dimensions and fake adformat (to auto-select from list when editing) (NO CUSTOM OPTIONS)
122
+ if(preg_match('/shoppingads_ad_height(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-height'] = $matches[3]; }
123
+ if(preg_match('/shoppingads_ad_width(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-width'] = $matches[3]; }
124
+ $_POST['adsensem-adformat']=$_POST['adsensem-width'] . 'x' . $_POST['adsensem-height'];
125
+
126
+ if(preg_match('/shoppingads_ad_kw(\s*)=(\s*)"([^"]*)"/', $code, $matches)!=0){ $_POST['adsensem-keywords'] = $matches[3]; }
127
+
128
+ if(preg_match('/shoppingads_color_border(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-color-border'] = $matches[3]; }
129
+ if(preg_match('/shoppingads_color_bg(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-color-bg'] = $matches[3]; }
130
+ if(preg_match('/shoppingads_color_heading(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-color-title'] = $matches[3]; }
131
+ if(preg_match('/shoppingads_color_text(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-color-text'] = $matches[3]; }
132
+ if(preg_match('/shoppingads_color_link(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-color-link'] = $matches[3]; }
133
+
134
+ if(preg_match('/shoppingads_attitude(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-attitude'] = $matches[3]; }
135
+ if(preg_match('/shoppingads_options(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ ($matches[3]=='n')?$_POST['adsensem-new-window']='yes':$_POST['adsensem-new-window']='no'; }
136
+
137
+ if(preg_match('/shoppingads_ad_client(\s*)=(\s*)"(\w*)"/', $code, $matches)!=0){ $_POST['adsensem-account-id'] = $matches[3]; }
138
+
139
+ $this->save_settings();
140
+ }
141
+
142
+ function _form_settings_colors(){
143
+ $this->_form_settings_colors_generate(array('Border'=>'border','Description'=>'title','Background'=>'bg','Price'=>'text','Footer'=>'link'));
144
+ }
145
+
146
+ function _form_settings_colors_demo(){
147
+ ?>
148
+ <div id="ad-color-bg" style="margin-top:1em;width:120px;background: #<?php echo htmlspecialchars($this->pd('color-bg'), ENT_QUOTES); ?>;">
149
+ <div id="ad-color-border" style="font: 10px arial, sans-serif; border: 1px solid #<?php echo htmlspecialchars($this->pd('color-border'), ENT_QUOTES); ?>" class="linkunit-wrapper">
150
+ <img src="<?php echo get_bloginfo('wpurl') . '/wp-content/plugins/adsense-manager/shoppingads.png'?>" style="width:60%">
151
+ <div id="ad-color-title" style="color: #<?php echo htmlspecialchars($this->pd('color-title'), ENT_QUOTES); ?>; font: 11px verdana, arial, sans-serif; padding: 2px;">
152
+ <b><u>Description of Product</u></b><br /></div>
153
+ <div id="ad-color-text" style="color: #<?php echo htmlspecialchars($this->pd('color-text'), ENT_QUOTES); ?>; padding: 2px;" class="text">
154
+ Current Bid: $5.00<br /></div>
155
+ <div id="ad-color-link" style="color: #<?php echo htmlspecialchars($this->pd('color-link'), ENT_QUOTES); ?>; font: 10px verdana, arial, sans-serif; padding: 2px;">
156
+ &nbsp;<span style="text-decoration:underline">Ads by <?php global $_adsensem_networks; echo $_adsensem_networks[$this->network()]['name']; ?></span></div>
157
+ </div>
158
+ <?php
159
+ }
160
+
161
+ function _form_settings_campaign(){
162
+ adsensem_admin::_field_input('Campaign','alternate-campaign',$this->p['alternate-campaign'],25,'Campaign identifier for this unit.');
163
+ adsensem_admin::_field_input('Keywords','alternate-keywords',$this->p['alternate-keywords'],25,'Keywords for this unit');
164
+ }
165
+
166
+ function _form_settings_style(){
167
+ $default=array('' => 'Use Default');
168
+ $attitude = array('true' => 'Classic','false' => 'Basic','cool' => 'Cool Blue','fader'=>'Ad Fader','etched'=>'Etched');
169
+ $yesno = array('yes' => 'Yes','no' => 'No');
170
+ adsensem_admin::_field_select('Attitude','attitude',$yesno,$this->p['attitude']);
171
+ adsensem_admin::_field_select('Open New Window','new-window',$yesno,$this->p['new-window']);
172
+ }
173
+
174
+ function _form_settings_ad_unit(){
175
+ adsensem_admin::_field_input('Name','name',$this->name,15,'Name for this Ad Unit');
176
+ ?><input name="adsensem-name-old" type="hidden" value="<?php echo htmlspecialchars($this->name, ENT_QUOTES); ?>" /><?php
177
+ }
178
+
179
+ function _var_ad_formats_available(){
180
+ $formats['horizontal']=array('728x90' => '728 x 90 Leaderboard', '468x60' => '468 x 60 Banner', '234x60' => '234 x 60 Half Banner');
181
+ $formats['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x600' => '160 x 600 Wide Skyscraper', '120x240' => '120 x 240 Vertical Banner');
182
+ $formats['square']=array('336x280' => '336 x 280 Large Rectangle', '300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square', '180x150' => '180 x 150 Small Rectangle', '125x125' => '125 x 125 Button');
183
+ return $formats;
184
+ }
185
+
186
+
187
+ //Middle
188
+ function admin_manage_column2(){
189
+ adsensem_admin::manage_dbxoutput(array('campaign','ad_format','style','colors'));
190
+ }
191
+
192
+
193
+ }
194
+
195
+ ?>
class-upgrade.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class adsensem_upgrade {
4
+
5
+ function go(){
6
+ global $_adsensem;
7
+
8
+ /* Store backup of previous version array */
9
+
10
+ /* List of possible upgrade paths here: Ensure that versions automagically stack on top of one another
11
+ e.g. v1.x to v3.x should be possilbe v1.x > v2.x > v3.x */
12
+
13
+ if($_adsensem['version']<3.0){adsensem_upgrade::v2_x_to_3_0();}
14
+
15
+ if(!is_numeric($_adsensem['be-nice'])){ $_adsensem['be-nice'] = ADSENSEM_BE_NICE; }
16
+ $_adsensem['version']=ADSENSEM_VERSION;
17
+ }
18
+
19
+ function v2_x_to_3_0(){
20
+ global $_adsensem;
21
+
22
+ $old=$_adsensem;
23
+
24
+ /* VERSION 3.x */
25
+ $_adsensem['ads'] = array();
26
+
27
+ $_adsensem['be-nice'] = $old['benice'];
28
+ $_adsensem['default-ad'] = $old['defaults']['ad'];
29
+
30
+ $_adsensem['defaults']=array();
31
+ $_adsensem['defaults']['Ad_AdSense_Classic']=adsensem_upgrade::_process_v2_x_to_3_0($old['defaults']);
32
+ /* Copy AdSense account-id to both class/new settings */
33
+ $_adsensem['account-ids']['Ad_AdSense']=$old['adsense-account'];
34
+ //$_adsensem['defaults']['Ad_AdSense_Classic']['account-id']=$old['adsense-account'];
35
+
36
+ /* Now all that remains is to convert the ads. In 2.x ads were stored as simply arrays containing the options.
37
+ To upgrade create new objects using product/slot/etc. info, or for code units run an import cycle. */
38
+
39
+ foreach($old['ads'] as $oname=>$oad){
40
+
41
+ if($oad['slot']!=''){$type='slot';}
42
+ else {$type=$oad['product'];}
43
+
44
+ $name=adsensem_admin::validate_name($oname);
45
+
46
+ switch($type){
47
+
48
+ /* AdSense Referral */
49
+ case 'code':
50
+ $ad=adsensem_admin::import_ad($oad['html-code']);
51
+ $_adsensem['ads'][$name]=$ad;
52
+ $_adsensem['ads'][$name]->name=$name;
53
+ break;
54
+
55
+ /* AdSense Slot Ads */
56
+ case 'slot':
57
+ $ad=new Ad_AdSense();
58
+ $_adsensem['ads'][$name]=$ad;
59
+ $_adsensem['ads'][$name]->name=$name;
60
+ $_adsensem['ads'][$name]->p=adsensem_upgrade::_process_v2_x_to_3_0($oad);
61
+ break;
62
+ /* AdSense Ad */
63
+ case 'ad':
64
+ $ad=new Ad_AdSense_Ad();
65
+ $_adsensem['ads'][$name]=$ad;
66
+ $_adsensem['ads'][$name]->name=$name;
67
+ $_adsensem['ads'][$name]->p=adsensem_upgrade::_process_v2_x_to_3_0($oad);
68
+ break;
69
+ case 'link':
70
+ $ad=new Ad_AdSense_Link();
71
+ $_adsensem['ads'][$name]=$ad;
72
+ $_adsensem['ads'][$name]->name=$name;
73
+ $_adsensem['ads'][$name]->p=adsensem_upgrade::_process_v2_x_to_3_0($oad);
74
+ break;
75
+
76
+ case 'referral':
77
+ case 'referral-image':
78
+ case 'referral-text':
79
+ $ad=new Ad_AdSense_Referral();
80
+ $_adsensem['ads'][$name]=$ad;
81
+ $_adsensem['ads'][$name]->name=$name;
82
+ $_adsensem['ads'][$name]->p=adsensem_upgrade::_process_v2_x_to_3_0($oad);
83
+ break;
84
+ }
85
+
86
+ }
87
+
88
+ $_adsensem['ads']=adsensem_admin::sort_ads_by_network($_adsensem['ads']);
89
+ }
90
+
91
+
92
+ function _process_v2_x_to_3_0($old){
93
+ $new=$old;
94
+
95
+ /* Additional conversaion required for rearrangement of colors system */
96
+ $new['color-border']=$old['colors']['border'];
97
+ $new['color-title']=$old['colors']['link'];
98
+ $new['color-bg']=$old['colors']['bg'];
99
+ $new['color-text']=$old['colors']['text'];
100
+ $new['color-url']=$old['colors']['url'];
101
+ /* End color rearrangement */
102
+ $new['show-page']=$old['show-post'];
103
+
104
+ /* Adformat codes etc. need to be moved */
105
+ switch($old['product']){
106
+ case 'ad':
107
+ if($old['alternate-url']){ $new['alternate-ad']='url'; } else { $new['alternate-ad']='color'; }
108
+ break;
109
+ case 'link':
110
+ $new['adformat']=$old['linkformat'];
111
+ $new['adtype']=$old['linktype'];
112
+ break;
113
+ case 'referral':
114
+ case 'referral-text':
115
+ $new['adformat']=$old['referralformat'];
116
+ break;
117
+ }
118
+
119
+
120
+
121
+ return $new;
122
+ }
123
+
124
+
125
+ function adsense_deluxe_to_3_0(){
126
+ global $_adsensem;
127
+ $deluxe=get_option('acmetech_adsensedeluxe');
128
+
129
+ foreach($deluxe['ads'] as $key => $vals){
130
+ $ad=adsensem_admin::import_ad($vals['code']);
131
+ $name=adsensem_admin::validate_name($vals['name']);
132
+
133
+ $_adsensem['ads'][$name]=$ad;
134
+ $_adsensem['ads'][$name]->name=$name;
135
+
136
+ $_adsensem['ads'][$name]->p['show-home']=($deluxe['enabled_for']['home']==1)?'yes':'no';
137
+ $_adsensem['ads'][$name]->p['show-post']=($deluxe['enabled_for']['posts']==1)?'yes':'no';
138
+ $_adsensem['ads'][$name]->p['show-archive']=($deluxe['enabled_for']['archives']==1)?'yes':'no';
139
+ $_adsensem['ads'][$name]->p['show-page']=($deluxe['enabled_for']['page']==1)?'yes':'no';
140
+
141
+ if($vals['make_default']==1){$_adsensem['default-ad']=$name;}
142
+ }
143
+
144
+ $_adsensem['ads']=adsensem_admin::sort_ads_by_network($_adsensem['ads']);
145
+ }
146
+
147
+
148
+ }
149
+
150
+ ?>
class-widgetbucks.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!ADSENSEM_VERSION){die();}
4
+
5
+ $_adsensem_networks['Ad_WidgetBucks'] = array(
6
+ 'name' => 'WidgetBucks',
7
+ 'shortname' => 'widget',
8
+ 'www' => 'http://www.widgetbucks.com/',
9
+ 'www-create' => 'http://www.widgetbucks.com/widget.page?action=call&widgetID=',
10
+ 'www-signup' => 'http://www.widgetbucks.com/home.page?referrer=468034'
11
+ );
12
+
13
+ /*
14
+
15
+ INITIALISATION
16
+ All functions in here called at startup (after other plugins have loaded, in case
17
+ we need to wait for the widget-plugin).
18
+ */
19
+
20
+ class Ad_WidgetBucks extends Ad_Generic {
21
+
22
+ function Ad_WidgetBucks(){
23
+ $this->Ad_Generic();
24
+ }
25
+
26
+
27
+ function render_ad(){
28
+
29
+ $code ='';
30
+ $code .= '<!-- START CUSTOM WIDGETBUCKS CODE --><div>';
31
+ $code .= '<script src="http://api.widgetbucks.com/script/ads.js?uid=' . $this->pd('slot') . '"></script>';
32
+ $code .= '</div><!-- END CUSTOM WIDGETBUCKS CODE -->';
33
+ return $code;
34
+
35
+ }
36
+
37
+ function save_settings_network() {
38
+
39
+ $this->p['slot']=strip_tags(stripslashes($_POST['adsensem-slot']));
40
+ $this->p['code']=stripslashes($_POST['adsensem-code']);
41
+
42
+ }
43
+
44
+
45
+ function import_detect_network($code){
46
+
47
+ return ( preg_match('/http:\/\/....widgetbucks.com\/script\/ads.js\?uid=/', $code, $matches) !==0);
48
+
49
+ }
50
+
51
+ function import_settings($code){
52
+
53
+ if(preg_match("/http:\/\/....widgetbucks.com\/script\/ads.js\?uid=(\w*)\"/", $code, $matches)!=0){
54
+ //ACCOUNT ID? NEEDS DEFAULT IMPORT RULES. GAH.
55
+ //$_POST['adsensem-account-id'] = $matches[3];
56
+ $_POST['adsensem-slot'] = $matches[1];
57
+ }
58
+
59
+ $this->save_settings();
60
+ }
61
+
62
+
63
+ function _form_settings_network(){
64
+ ?><td><td><p>No network settings.</p></td></tr>
65
+ <?php
66
+ }
67
+
68
+ function _form_settings_help(){
69
+ ?><tr><td><p>Configuration is available through the <a href="http://www.widgetbucks.com/" target="_blank">WidgetBucks site</a>.
70
+ Account maintenance links:</p>
71
+ <ul>
72
+ <li><a href="http://www.widgetbucks.com/myWidgets.page?action=call" target="_blank">My Widgets</a><br />
73
+ View, manage and create widgets.</li>
74
+ <li><a href="http://www.widgetbucks.com/myBucks.page?action=call" target="_blank">My Bucks</a><br />
75
+ View your account balance and payment schedule.</li>
76
+ <li><a href="https://www.widgetbucks.com/mySettings.page?action=call" target="_blank">My Settings</a><br />
77
+ Change account details and other global settings.</li>
78
+ </ul>
79
+ </td></tr><?php
80
+ }
81
+
82
+
83
+ function _var_ad_formats_available(){
84
+ $formats['horizontal']=array('728x90' => '728 x 90 Leaderboard', '660x330' => '660 x 330 Custom', '468x60' => '468 x 60 Banner');
85
+ $formats['vertical']=array('120x600' => '120 x 600 Skyscraper', '160x300' => '160 x 300 Blog Sidebar', '160x600' => '160 x 600 Wide Skyscraper');
86
+ $formats['square']=array('300x250' => '300 x 250 Medium Rectangle', '250x250' => '250 x 250 Square');
87
+ return $formats;
88
+ }
89
+
90
+ //Middle
91
+ function admin_manage_column2(){
92
+ adsensem_admin::manage_dbxoutput(array('ad_format'));
93
+ }
94
+
95
+
96
+
97
+ }
98
+
99
+ ?>
code.png ADDED
Binary file
editor_plugin.js ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Import plugin specific language pack */
2
+ tinyMCE.importPluginLanguagePack('adsense_deluxe', '');
3
+
4
+ function TinyMCE_adsense_deluxe_initInstance(inst) {
5
+ tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/adsense_deluxe/adsense_deluxe.css");
6
+ }
7
+
8
+ /**
9
+ * Information about the plugin.
10
+ */
11
+ function TinyMCE_g2image_getInfo() {
12
+ return {
13
+ longname : 'Adsense Deluxe plugin',
14
+ author : 'Wayne K Walrath',
15
+ authorurl : 'http://www.acmetech.com/blog/',
16
+ infourl : 'http://www.acmetech.com/blog/',
17
+ version : "0.7"
18
+ };
19
+ };
20
+
21
+ function TinyMCE_adsense_deluxe_getControlHTML(control_name) {
22
+ //class="mce_ads_dlx_SelectList"
23
+ switch (control_name) {
24
+ case "adsense_deluxe":
25
+ var html = '<select id="{$editor_id}_adsense_select" name="{$editor_id}_adsense_select" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mce_adsense_select\',false,this.options[this.selectedIndex].value);this.selectedIndex=0;" class="mceSelectList" style="font-size:8pt;">';
26
+ html += '<option value="">--AdSense--</option>';
27
+
28
+ // Build format select
29
+ html += '<option value="adsense">' + "adsense" + '</option>';
30
+ if( __ADSENSE_DELUXE_ADS != null ){
31
+ for(var i=0; i<__ADSENSE_DELUXE_ADS.length; i++){
32
+ html += '<option value="adsense#' + __ADSENSE_DELUXE_ADS[i] + '">' + "&nbsp;&nbsp;&nbsp;adsense#" + __ADSENSE_DELUXE_ADS[i] + '</option>';
33
+ }
34
+
35
+ }
36
+
37
+ html += '</select>';
38
+ //ad_select
39
+
40
+ return html;
41
+
42
+ var title_adsense = tinyMCE.getLang('lang_adsense_deluxe_button');
43
+ var buttons = '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mce_ads_deluxe\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mce_ads_deluxe\');return false;"><img id="{$editor_id}_adsdlx" src="{$pluginurl}/images/adsense-deluxe.gif" title="'+title_adsense+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
44
+
45
+ return buttons;
46
+ }
47
+
48
+ return '';
49
+ }
50
+
51
+ function TinyMCE_adsense_deluxe_parseAttributes(attribute_string) {
52
+ var attributeName = "";
53
+ var attributeValue = "";
54
+ var withInName;
55
+ var withInValue;
56
+ var attributes = new Array();
57
+ var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
58
+ var titleText = tinyMCE.getLang('lang_wordpress_more');
59
+ var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
60
+
61
+ if (attribute_string == null || attribute_string.length < 2)
62
+ return null;
63
+
64
+ withInName = withInValue = false;
65
+
66
+ for (var i=0; i<attribute_string.length; i++) {
67
+ var chr = attribute_string.charAt(i);
68
+
69
+ if ((chr == '"' || chr == "'") && !withInValue)
70
+ withInValue = true;
71
+ else if ((chr == '"' || chr == "'") && withInValue) {
72
+ withInValue = false;
73
+
74
+ var pos = attributeName.lastIndexOf(' ');
75
+ if (pos != -1)
76
+ attributeName = attributeName.substring(pos+1);
77
+
78
+ attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();
79
+
80
+ attributeName = "";
81
+ attributeValue = "";
82
+ } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
83
+ withInName = true;
84
+
85
+ if (chr == '=' && withInName)
86
+ withInName = false;
87
+
88
+ if (withInName)
89
+ attributeName += chr;
90
+
91
+ if (withInValue)
92
+ attributeValue += chr;
93
+ }
94
+
95
+ return attributes;
96
+ }
97
+
98
+ function TinyMCE_adsense_deluxe_execCommand(editor_id, element, command, user_interface, value) {
99
+ var inst = tinyMCE.getInstanceById(editor_id);
100
+ var focusElm = inst.getFocusElement();
101
+ var doc = inst.getDoc();
102
+
103
+ function getAttrib(elm, name) {
104
+ return elm.getAttribute(name) ? elm.getAttribute(name) : "";
105
+ }
106
+
107
+ // Handle commands
108
+ switch (command) {
109
+ case "mce_adsense_select":
110
+ //var rc = alert("Value = " + value);
111
+ //element.selectedIndex = 0; // reset menu
112
+ //return true;
113
+
114
+ case "mce_ads_deluxe":
115
+ var flag = "";
116
+ var template = new Array();
117
+ var altMore = tinyMCE.getLang('lang_adsense_deluxe_alt');
118
+
119
+ // Is selection a image
120
+ if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
121
+ flag = getAttrib(focusElm, 'class');
122
+
123
+ if (flag != 'mce_plugin_adsense_deluxe') // Not a wordpress
124
+ return true;
125
+
126
+ action = "update";
127
+ }
128
+
129
+ html = TinyMCE_adsense_deluxe_make_imgtag(value);
130
+ tinyMCE.execCommand("mceInsertContent",true,html);
131
+ tinyMCE.selectedInstance.repaint();
132
+ return true;
133
+
134
+ }
135
+
136
+ // Pass to next handler in chain
137
+ return false;
138
+ }
139
+
140
+ function TinyMCE_adsense_deluxe_make_imgtag(ad_name){
141
+ var html = ''
142
+ + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
143
+ + ' width="80" height="16" '
144
+ + 'alt="'+ad_name+'" title="'+ ad_name +'" class="mce_plugin_adsense_deluxe" name="mce_plugin_adsense_deluxe" />';
145
+ return html;
146
+ }
147
+ function TinyMCE_adsense_deluxe_cleanup(type, content) {
148
+ // return content;
149
+
150
+
151
+ switch (type) {
152
+
153
+ case "insert_to_editor":
154
+ //--
155
+ //-- This doesn't handle the situation where you have AdsDlx tags
156
+ //-- with ad names which were deleted from AdsDlx options after
157
+ //-- the post was originally created. E.g., you inserted <!--adsense#foo-->
158
+ //-- published that post, then later you're editing the post but the "foo"
159
+ //-- ads no longer existin in the plugin options.
160
+ //-- [suggested "ToDo" for that:
161
+ var startPos = 0;
162
+ var altMore = tinyMCE.getLang('lang_adsense_deluxe_alt');
163
+ var ad_names = new Array('adsense');
164
+ if( __ADSENSE_DELUXE_ADS != null ){
165
+ for(var i=0; i<__ADSENSE_DELUXE_ADS.length; i++){
166
+ ad_names.push('adsense#' + __ADSENSE_DELUXE_ADS[i]);
167
+ }
168
+ }
169
+
170
+ // Parse all <!--adsense--> tags and replace them with images
171
+ for(var i=0; i<ad_names.length; i++){
172
+ startPos = 0;
173
+ //alert('<!--'+ad_names[i]+'-->');
174
+ while ((startPos = content.indexOf('<!--'+ad_names[i]+'-->', startPos)) != -1) {
175
+ // Insert image
176
+ var contentAfter = content.substring(startPos + ad_names[i].length+7);
177
+ content = content.substring(0, startPos);
178
+ content += TinyMCE_adsense_deluxe_make_imgtag(ad_names[i]);
179
+ content += contentAfter;
180
+
181
+ startPos++;
182
+ }
183
+ // go to next ad placeholder
184
+ }
185
+
186
+ // If any blocks weren't replaced, do it with this statement
187
+ content = content.replace(new RegExp('<!--adsense#([^-]+)-->', 'g'), '<strong style="color:red">[Undefined Adsense Block ($1)]</strong>');
188
+
189
+ break;
190
+
191
+ case "get_from_editor":
192
+ // Parse all img tags and replace them with <!--adsense-->
193
+ var startPos = -1;
194
+ while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
195
+ var endPos = content.indexOf('/>', startPos);
196
+ var attribs = TinyMCE_adsense_deluxe_parseAttributes(content.substring(startPos + 4, endPos));
197
+
198
+ if (attribs['class'] == "mce_plugin_adsense_deluxe") {
199
+ endPos += 2;
200
+
201
+ var embedHTML = '<!--adsense-->';
202
+ if( attribs['title'] != null && attribs['title'] != '' )
203
+ embedHTML = '<!--' + attribs['title'] + '-->';
204
+
205
+ // Insert embed/object chunk
206
+ chunkBefore = content.substring(0, startPos);
207
+ chunkAfter = content.substring(endPos);
208
+ content = chunkBefore + embedHTML + chunkAfter;
209
+ }
210
+ }
211
+
212
+ // If it says & in the WYSIWYG editor, it should say &amp; in the html.
213
+ // content = content.replace(new RegExp('&', 'g'), '&amp;');
214
+ // content = content.replace(new RegExp('&amp;nbsp;', 'g'), '&nbsp;');
215
+
216
+
217
+ break;
218
+ }
219
+
220
+ // Pass through to next handler in chain
221
+ return content;
222
+ }
223
+
224
+ function TinyMCE_adsense_deluxe_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
225
+
226
+ return false;
227
+ function getAttrib(elm, name) {
228
+ return elm.getAttribute(name) ? elm.getAttribute(name) : "";
229
+ }
230
+
231
+ tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal');
232
+
233
+ if (node == null)
234
+ return;
235
+
236
+ do {
237
+ if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
238
+ tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
239
+ if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
240
+ tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
241
+ } while ((node = node.parentNode));
242
+
243
+ return true;
244
+ }
readme.txt CHANGED
@@ -1,48 +1,70 @@
1
  === AdSense Manager ===
2
  Contributors: mutube
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=martin%2efitzpatrick%40gmail%2ecom&item_name=Donation%20to%20mutube%2ecom&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8
4
- Tags: adsense, ads, manage, widget, google
5
- Requires at least: 2.0.2
6
- Tested up to: 2.3
7
- Stable tag: 2.5
8
 
9
- AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It generates code automatically and allows positioning with Widgets.
10
 
11
  == Description ==
12
 
13
  AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It generates code automatically and allows positioning with Widgets.
14
 
15
- Version 2.5 now supports:
16
- * Referral Ads (Text & Image)
17
- * Direct Code Ads (allows for non AdSense ad positioning)
18
- * Code Converter (import Google generated Ads to configurable Ad units)
19
- * Sidebar Modules (as used in the popular K2 theme)
20
- * [New extended instructions available.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
21
-
22
- Be Nice is Back! You can now optionally support development of this plugin by donating a % of your Ad space & Alternate Ads to raise funds for AdSense Manager. This new method is completely compatible with Google's T&Cs and all ads are hand-selected and guaranteed to be family friendly. Thanks for your support, it makes a difference!
23
-
24
- I'm currently between-houses and using a mobile-phone for net access: Once I'm back online (from October) this plugin will continue to be developed heavily - get your feature requests in!
25
-
26
- Current top priority is support for Google's new Referral formats - watch this space.
27
-
28
 
29
- Updated to work with new Wordpress 2.2 Widgets. This may break Sidebar Module support, let me know how you get on with it. They seem pretty incompatible now Widgets are built in.
30
 
31
  == Installation ==
32
 
33
  1. Unzip the downloaded package and upload the Adsense Manager folder into your Wordpress plugins folder
34
  1. Log into your WordPress admin panel
35
  1. Go to Plugins and “Activate” the plugin
36
- 1. “Adsense Manager” will now be displayed in your Options section and “Ads” appears under Manage.
37
- 1. Set your AdSense Account ID under Options &raquo; AdSense
38
- 1. Create and modify your Ad blocks under Manage &raquo; Ads
39
- 1. [Complete usage instructions are available here.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
 
40
 
41
  == Frequently Asked Questions ==
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  = Where can I get more information? =
44
 
45
- [Complete usage instructions are available here.](http://www.mutube.com/projects/wordpress/adsense-manager/instructions)
 
 
46
 
47
  == Screenshots ==
48
 
1
  === AdSense Manager ===
2
  Contributors: mutube
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=martin%2efitzpatrick%40gmail%2ecom&item_name=Donation%20to%20mutube%2ecom&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8
4
+ Tags: adsense, ad, link, referral, manage, widget, google, adbrite, cj, adpinion, shoppingads, widgetbucks
5
+ Requires at least: 2.3.3
6
+ Tested up to: 2.3.3
7
+ Stable tag: 3.0
8
 
9
+ AdSense Manager is a Wordpress plugin for managing AdSense and other networks on your blog. It generates code automatically and allows position with widgets, code or inline tags.
10
 
11
  == Description ==
12
 
13
  AdSense Manager is a Wordpress plugin for managing AdSense ads on your blog. It generates code automatically and allows positioning with Widgets.
14
 
15
+ Version 3.0 now supports:
16
+ [AdSense](http://www.google.com/adsense), [Adpinion](http://www.adpinion.com/), [AdBrite](http://www.adbrite.com/mb/landing_both.php?spid=51549&afb=120x60-1-blue), [Adroll](http://re.adroll.com/a/D44UNLTJPNH5ZDXTTXII7V/7L73RCFU5VCG7FRNNIGH7O/d6ca1e265e654df2010a2153d5c42ed4.re), [Commission Junction](http://www.cj.com/), [ShoppingAds](http://www.shoppingads.com/refer_1ebff04bf5805f6da1b4) and [WidgetBucks](http://www.widgetbucks.com/home.page?referrer=468034).
17
+ Automatic Ad Code Importer for all supported networks.
18
+ Widgets & Sidebar Modules compatible (as used in the popular K2 theme).
19
+ [Extended instructions are available here...](http://www.mutube.com/mu/getting-started-with-adsense-manager-3x).
 
 
 
 
 
 
 
 
20
 
21
+ You optionally support development of this plugin by donating a % of your Ad space & Alternate Ads to raise funds for AdSense Manager. All ads are hand-selected and guaranteed to be family friendly. Thanks for your support, it makes a difference!
22
 
23
  == Installation ==
24
 
25
  1. Unzip the downloaded package and upload the Adsense Manager folder into your Wordpress plugins folder
26
  1. Log into your WordPress admin panel
27
  1. Go to Plugins and “Activate” the plugin
28
+ 1. Previous installations will be updated and a notice displayed. If you have not used AdSense Manager before but have used AdSense Deluxe, you will be offered the change to import those ads.
29
+ 1. “Adsense Manager” will now be displayed in your Options section and “Ad Units” appears under Manage.
30
+ 1. For first step instructions, go to Options &raquo; AdSense
31
+ 1. Import, create and modifty your Ad blocks under Manage &raquo; Ad Units
32
+ 1. [Complete usage instructions are available here.](http://www.mutube.com/mu/getting-started-with-adsense-manager-3x)
33
 
34
  == Frequently Asked Questions ==
35
 
36
+ = What is Be Nice? =
37
+
38
+ Be Nice is a way for you to support development of this plugin without donating hard cash. Under Options &raquo; AdSense you can select to donate a percentage of your ad space to development of this plugin. It won't make me rich (I wish) but it does help guarantee development time and played an important role in putting aside time for v3.x rewrites.
39
+
40
+ = What if I'm Not Nice? =
41
+
42
+ Nothing. It's entirely up to you: the plugin will function identically whether you donate ad space or not. If you are able [please consider making a PayPal donation instead](https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=martin%2efitzpatrick%40gmail%2ecom&item_name=Donation%20to%20mutube%2ecom&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8).
43
+
44
+ = What do you spend the money on? =
45
+
46
+ Food, clothes, course books, etc. I'm currently studying [this](http://www.undergraduate.bham.ac.uk/coursefinder/medicine/medical-sci.shtml), [here](http://www.bham.ac.uk).
47
+
48
+ = Why does changing Ad Format/Dimensions sometimes not change the size of the ad? =
49
+
50
+ For some ad networks (e.g. WidgetBucks, Adroll, etc.) the dimensions of ads are managed through the online interface. There is no way to change these settings from within the WordPress system that would work reliably. You do not have to update these dimension settings if you update your Ad online, however, it can be useful in correctly identifying 'Alternate Ads' for AdSense blocks.
51
+
52
+ = Do I still need AdSense Manager now I can manage ads through Google's system? =
53
+
54
+ Yes and no. While the original purpose of being able to modify colours etc. without digging into code is now gone (although still supported) there are other advantages to AdSense Manager. For example: positioning. Additionally there are some plans afoot to provide intelligent ad placing methods to make all this work even better.
55
+
56
+ = What else do you have planned? =
57
+
58
+ 1. Ad Zones to allow grouping of ads at a particular location, and switching depending on the visitors language, country, etc.
59
+ 1. Auto-inserting of ads into posts based on configurable rules (i.e. All Posts, 2nd Paragraph)
60
+ 1. Localisation: multi-language support
61
+ 1. Support for Amazon Affiliates, Yahoo! Publisher Network, and any other networks I hear about.
62
+
63
  = Where can I get more information? =
64
 
65
+ [Complete usage instructions are available here.](http://www.mutube.com/mu/getting-started-with-adsense-manager-3x)
66
+
67
+
68
 
69
  == Screenshots ==
70
 
shoppingads.png ADDED
Binary file