Quick Adsense - Version 1.9.4

Version Description

  • The number of individual database calls has been reduced from 80 to just 1, also almost all of the legacy code has been altered and code base re-structured to be better understandable.
  • Security: improved.
  • Info update.
  • Date: 20-September-2017
Download this release

Release Info

Developer quickadsense
Plugin Icon 128x128 Quick Adsense
Version 1.9.4
Comparing to
See all releases

Code changes from version 1.9.2 to 1.9.4

includes/ads.php ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $ShownAds = 0;
3
+ $AdsId = array();
4
+ $beginend = 0;
5
+ $wpvcomp = (bool)(version_compare($wp_version, '3.1', '>='));
6
+
7
+ if($wpvcomp) {
8
+ add_action('admin_print_footer_scripts', 'quick_adsense_2_admin_print_footer_scripts');
9
+ }else{
10
+ add_action('admin_head', 'quick_adsense_2_admin_print_footer_scripts');
11
+ }
12
+ function quick_adsense_2_admin_print_footer_scripts() {
13
+ global $QData;
14
+ global $wpvcomp;
15
+ $options = quick_adsense_2_get_options_with_defaults();
16
+ if ($options['QckTags']) { ?>
17
+ <script type="text/javascript">
18
+ wpvcomp = <?php echo(($wpvcomp==1)?"true":"false"); ?>;
19
+ edaddID = new Array();
20
+ edaddNm = new Array();
21
+ if(typeof(edButtons)!='undefined') {
22
+ edadd = edButtons.length;
23
+ var dynads={"all":[
24
+ <?php for ($i=1;$i<=$QData['Ads'];$i++) { if($options['AdsCode'.$i]!=''){echo('"1",');}else{echo('"0",');}; } ?>
25
+ "0"]};
26
+ for(i=1;i<=<?php echo($QData['Ads']) ?>;i++) {
27
+ if(dynads.all[i-1]=="1") {
28
+ edButtons[edButtons.length]=new edButton("ads"+i.toString(),"Ads"+i.toString(),"\n<!--Ads"+i.toString()+"-->\n","","",-1);
29
+ edaddID[edaddID.length] = "ads"+i.toString();
30
+ edaddNm[edaddNm.length] = "Ads"+i.toString();
31
+ }
32
+ }
33
+ <?php if(!$options['QckRnds']){ ?>
34
+ edButtons[edButtons.length]=new edButton("random_ads","RndAds","\n<!--RndAds-->\n","","",-1);
35
+ edaddID[edaddID.length] = "random_ads";
36
+ edaddNm[edaddNm.length] = "RndAds";
37
+ <?php } ?>
38
+ <?php if(!$options['QckOffs']){ ?>
39
+ edButtons[edButtons.length]=new edButton("no_ads","NoAds","\n<!--NoAds-->\n","","",-1);
40
+ edaddID[edaddID.length] = "no_ads";
41
+ edaddNm[edaddNm.length] = "NoAds";
42
+ edButtons[edButtons.length]=new edButton("off_def","OffDef","\n<!--OffDef-->\n","","",-1);
43
+ edaddID[edaddID.length] = "off_def";
44
+ edaddNm[edaddNm.length] = "OffDef";
45
+ edButtons[edButtons.length]=new edButton("off_wid","OffWidget","\n<!--OffWidget-->\n","","",-1);
46
+ edaddID[edaddID.length] = "off_wid";
47
+ edaddNm[edaddNm.length] = "OffWidget";
48
+ <?php } ?>
49
+ <?php if(!$options['QckOfPs']){ ?>
50
+ edButtons[edButtons.length]=new edButton("off_bgn","OffBegin","\n<!--OffBegin-->\n","","",-1);
51
+ edaddID[edaddID.length] = "off_bgn";
52
+ edaddNm[edaddNm.length] = "OffBegin";
53
+ edButtons[edButtons.length]=new edButton("off_mid","OffMiddle","\n<!--OffMiddle-->\n","","",-1);
54
+ edaddID[edaddID.length] = "off_mid";
55
+ edaddNm[edaddNm.length] = "OffMiddle";
56
+ edButtons[edButtons.length]=new edButton("off_end","OffEnd","\n<!--OffEnd-->\n","","",-1);
57
+ edaddID[edaddID.length] = "off_end";
58
+ edaddNm[edaddNm.length] = "OffEnd";
59
+ edButtons[edButtons.length]=new edButton("off_more","OffAfMore","\n<!--OffAfMore-->\n","","",-1);
60
+ edaddID[edaddID.length] = "off_more";
61
+ edaddNm[edaddNm.length] = "OffAfMore";
62
+ edButtons[edButtons.length]=new edButton("off_last","OffBfLastPara","\n<!--OffBfLastPara-->\n","","",-1);
63
+ edaddID[edaddID.length] = "off_last";
64
+ edaddNm[edaddNm.length] = "OffBfLastPara";
65
+ <?php } ?>
66
+ };
67
+ (function(){
68
+ if(typeof(edButtons)!='undefined' && typeof(jQuery)!='undefined' && wpvcomp){
69
+ jQuery(document).ready(function(){
70
+ for(i=0;i<edaddID.length;i++) {
71
+ jQuery("#ed_toolbar").append('<input type="button" value="' + edaddNm[i] +'" id="' + edaddID[i] +'" class="ed_button" onclick="edInsertTag(edCanvas, ' + (edadd+i) + ');" title="' + edaddNm[i] +'" />');
72
+ }
73
+ });
74
+ }
75
+ }());
76
+ </script>
77
+ <?php }
78
+ }
79
+
80
+ add_filter('the_content', 'quick_adsense_2_the_content');
81
+ function quick_adsense_2_the_content($content) {
82
+ global $QData;
83
+ global $ShownAds;
84
+ global $AdsId;
85
+ global $beginend;
86
+ $options = quick_adsense_2_get_options_with_defaults();
87
+
88
+ /* verifying */
89
+ if( (is_feed()) ||
90
+ (strpos($content,'<!--NoAds-->')!==false) ||
91
+ (strpos($content,'<!--OffAds-->')!==false) ||
92
+ (is_single() && !(isset($options['AppPost']))) ||
93
+ (is_page() && !(isset($options['AppPage']))) ||
94
+ (is_home() && !(isset($options['AppHome']))) ||
95
+ (is_category() && !(isset($options['AppCate']))) ||
96
+ (is_archive() && !(isset($options['AppArch']))) ||
97
+ (is_tag() && !(isset($options['AppTags']))) ||
98
+ (is_user_logged_in() && (isset($options['AppLogg']))) ) {
99
+ $content = quick_adsense_2_clean_tags($content); return $content;
100
+ }
101
+
102
+ $AdsToShow = $options['AdsDisp'];
103
+ if (strpos($content,'<!--OffWidget-->')===false) {
104
+ for($i=1;$i<=$QData['AdsWid'];$i++) {
105
+ $wadsid = sanitize_title(str_replace(array('(',')'),'',sprintf($QData['AdsWidName'],$i)));
106
+ $AdsToShow -= (is_active_widget(true, $wadsid)) ? 1 : 0 ;
107
+ }
108
+ }
109
+ if( $ShownAds >= $AdsToShow ) { $content = quick_adsense_2_clean_tags($content); return $content; };
110
+
111
+ if( !count($AdsId) ) {
112
+ for($i=1;$i<=$QData['Ads'];$i++) {
113
+ $tmp = trim(((isset($options['AdsCode'.$i]))?$options['AdsCode'.$i]:''));
114
+ if( !empty($tmp) ) {
115
+ array_push($AdsId, $i);
116
+ }
117
+ }
118
+ }
119
+ if( !count($AdsId) ) { $content = quick_adsense_2_clean_tags($content); return $content; };
120
+
121
+ /* ... Tidy up content ... */
122
+ $content = str_replace("<p></p>", "##QA-TP1##", $content);
123
+ $content = str_replace("<p>&nbsp;</p>", "##QA-TP2##", $content);
124
+ $offdef = (strpos($content,'<!--OffDef-->')!==false);
125
+ if( !$offdef ) {
126
+ $AdsIdCus = array();
127
+ $cusads = 'CusAds'; $cusrnd = 'CusRnd';
128
+ $more1 = ((isset($options['MoreAds']))?$options['MoreAds']:''); $more2 = ((isset($options['MoreRnd']))?$options['MoreRnd']:'');
129
+ $lapa1 = ((isset($options['LapaAds']))?$options['LapaAds']:''); $lapa2 = ((isset($options['LapaRnd']))?$options['LapaRnd']:'');
130
+ $begn1 = ((isset($options['BegnAds']))?$options['BegnAds']:''); $begn2 = ((isset($options['BegnRnd']))?$options['BegnRnd']:'');
131
+ $midd1 = ((isset($options['MiddAds']))?$options['MiddAds']:''); $midd2 = ((isset($options['MiddRnd']))?$options['MiddRnd']:'');
132
+ $endi1 = ((isset($options['EndiAds']))?$options['EndiAds']:''); $endi2 = ((isset($options['EndiRnd']))?$options['EndiRnd']:'');
133
+ $rc=3;
134
+ for($i=1;$i<=$rc;$i++) {
135
+ $para1[$i] = ((isset($options['Par'.$i.'Ads']))?$options['Par'.$i.'Ads']:'');
136
+ $para2[$i] = ((isset($options['Par'.$i.'Rnd']))?$options['Par'.$i.'Rnd']:'');
137
+ $para3[$i] = ((isset($options['Par'.$i.'Nup']))?$options['Par'.$i.'Nup']:'');
138
+ $para4[$i] = ((isset($options['Par'.$i.'Con']))?$options['Par'.$i.'Con']:'');
139
+ }
140
+ $imge1 = ((isset($options['Img1Ads']))?$options['Img1Ads']:'');
141
+ $imge2 = ((isset($options['Img1Rnd']))?$options['Img1Rnd']:'');
142
+ $imge3 = ((isset($options['Img1Nup']))?$options['Img1Nup']:'');
143
+ $imge4 = ((isset($options['Img1Con']))?$options['Img1Con']:'');
144
+ if ( $begn2 == 0 ) { $b1 = $cusrnd; } else { $b1 = $cusads.$begn2; array_push($AdsIdCus, $begn2); };
145
+ if ( $more2 == 0 ) { $r1 = $cusrnd; } else { $r1 = $cusads.$more2; array_push($AdsIdCus, $more2); };
146
+ if ( $midd2 == 0 ) { $m1 = $cusrnd; } else { $m1 = $cusads.$midd2; array_push($AdsIdCus, $midd2); };
147
+ if ( $lapa2 == 0 ) { $g1 = $cusrnd; } else { $g1 = $cusads.$lapa2; array_push($AdsIdCus, $lapa2); };
148
+ if ( $endi2 == 0 ) { $b2 = $cusrnd; } else { $b2 = $cusads.$endi2; array_push($AdsIdCus, $endi2); };
149
+ for($i=1;$i<=$rc;$i++) {
150
+ if ( $para2[$i] == 0 ) { $b3[$i] = $cusrnd; } else { $b3[$i] = $cusads.$para2[$i]; array_push($AdsIdCus, $para2[$i]); };
151
+ }
152
+ if ( $imge2 == 0 ) { $b4 = $cusrnd; } else { $b4 = $cusads.$imge2; array_push($AdsIdCus, $imge2); };
153
+ if( $midd1 && strpos($content,'<!--OffMiddle-->')===false) {
154
+ if( substr_count(strtolower($content), '</p>')>=2 ) {
155
+ $sch = "</p>";
156
+ $content = str_replace("</P>", $sch, $content);
157
+ $arr = explode($sch, $content);
158
+ $nn = 0; $mm = strlen($content)/2;
159
+ for($i=0;$i<count($arr);$i++) {
160
+ $nn += strlen($arr[$i]) + 4;
161
+ if($nn>$mm) {
162
+ if( ($mm - ($nn - strlen($arr[$i]))) > ($nn - $mm) && $i+1<count($arr) ) {
163
+ $arr[$i+1] = '<!--'.$m1.'-->'.$arr[$i+1];
164
+ } else {
165
+ $arr[$i] = '<!--'.$m1.'-->'.$arr[$i];
166
+ }
167
+ break;
168
+ }
169
+ }
170
+ $content = implode($sch, $arr);
171
+ }
172
+ }
173
+ if( $more1 && strpos($content,'<!--OffAfMore-->')===false) {
174
+ $mmr = '<!--'.$r1.'-->';
175
+ $postid = get_the_ID();
176
+ $content = str_replace('<span id="more-'.$postid.'"></span>', $mmr, $content);
177
+ }
178
+ if( $begn1 && strpos($content,'<!--OffBegin-->')===false) {
179
+ $content = '<!--'.$b1.'-->'.$content;
180
+ }
181
+ if( $endi1 && strpos($content,'<!--OffEnd-->')===false) {
182
+ $content = $content.'<!--'.$b2.'-->';
183
+ }
184
+ if( $lapa1 && strpos($content,'<!--OffBfLastPara-->')===false){
185
+ $sch = "<p>";
186
+ $content = str_replace("<P>", $sch, $content);
187
+ $arr = explode($sch, $content);
188
+ if ( count($arr) > 2 ) {
189
+ $content = implode($sch, array_slice($arr, 0, count($arr)-1)) .'<!--'.$g1.'-->'. $sch. $arr[count($arr)-1];
190
+ }
191
+ }
192
+ for($i=$rc;$i>=1;$i--) {
193
+ if ( $para1[$i] ){
194
+ $sch = "</p>";
195
+ $content = str_replace("</P>", $sch, $content);
196
+ $arr = explode($sch, $content);
197
+ if ( (int)$para3[$i] < count($arr) ) {
198
+ $content = implode($sch, array_slice($arr, 0, $para3[$i])).$sch .'<!--'.$b3[$i].'-->'. implode($sch, array_slice($arr, $para3[$i]));
199
+ } elseif ($para4[$i]) {
200
+ $content = implode($sch, $arr).'<!--'.$b3[$i].'-->';
201
+ }
202
+ }
203
+ }
204
+ if ( $imge1 ){
205
+ $sch = "<img"; $bch = ">"; $cph = "[/caption]"; $csa = "</a>";
206
+ $content = str_replace("<IMG", $sch, $content);
207
+ $content = str_replace("</A>", $csa, $content);
208
+ $arr = explode($sch, $content);
209
+ if ( (int)$imge3 < count($arr) ) {
210
+ $trr = explode($bch, $arr[$imge3]);
211
+ if ( count($trr) > 1 ) {
212
+ $tss = explode($cph, $arr[$imge3]);
213
+ $ccp = ( count($tss) > 1 ) ? strpos(strtolower($tss[0]),'[caption ')===false : false ;
214
+ $tuu = explode($csa, $arr[$imge3]);
215
+ $cdu = ( count($tuu) > 1 ) ? strpos(strtolower($tuu[0]),'<a href')===false : false ;
216
+ if ( $imge4 && $ccp ) {
217
+ $arr[$imge3] = implode($cph, array_slice($tss, 0, 1)).$cph. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($cph, array_slice($tss, 1));
218
+ }else if ( $cdu ) {
219
+ $arr[$imge3] = implode($csa, array_slice($tuu, 0, 1)).$csa. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($csa, array_slice($tuu, 1));
220
+ }else{
221
+ $arr[$imge3] = implode($bch, array_slice($trr, 0, 1)).$bch. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($bch, array_slice($trr, 1));
222
+ }
223
+ }
224
+ $content = implode($sch, $arr);
225
+ }
226
+ }
227
+ }
228
+
229
+ /* ... Tidy up content ... */
230
+ $content = '<!--EmptyClear-->'.$content."\n".'<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>';
231
+ $content = quick_adsense_2_clean_tags($content, true);
232
+ $ismany = (!is_single() && !is_page());
233
+ $showall = ((isset($options['AppMaxA']))?$options['AppMaxA']:'');
234
+
235
+ /* ... Replace Beginning/Middle/End Ads1-10 ... */
236
+ if( !$offdef ) {
237
+ for( $i=1; $i<=count($AdsIdCus); $i++ ) {
238
+ if( $showall || !$ismany || $beginend != $i ) {
239
+ if( strpos($content,'<!--'.$cusads.$AdsIdCus[$i-1].'-->')!==false && in_array($AdsIdCus[$i-1], $AdsId)) {
240
+ $content = quick_adsense_2_replace_ads( $content, $cusads.$AdsIdCus[$i-1], $AdsIdCus[$i-1] ); $AdsId = quick_adsense_2_del_element($AdsId, array_search($AdsIdCus[$i-1], $AdsId)) ;
241
+ $ShownAds += 1; if( $ShownAds >= $AdsToShow || !count($AdsId) ){ $content = quick_adsense_2_clean_tags($content); return $content; };
242
+ $beginend = $i; if(!$showall && $ismany){break;}
243
+ }
244
+ }
245
+ }
246
+ }
247
+
248
+ /* ... Replace Ads1 to Ads10 ... */
249
+ if( $showall || !$ismany ) {
250
+ $tcn = count($AdsId); $tt = 0;
251
+ for( $i=1; $i<=$tcn; $i++ ) {
252
+ if( strpos($content, '<!--Ads'.$AdsId[$tt].'-->')!==false ) {
253
+ $content = quick_adsense_2_replace_ads( $content, 'Ads'.$AdsId[$tt], $AdsId[$tt] ); $AdsId = quick_adsense_2_del_element($AdsId, $tt) ;
254
+ $ShownAds += 1; if( $ShownAds >= $AdsToShow || !count($AdsId) ){ $content = quick_adsense_2_clean_tags($content); return $content; };
255
+ } else {
256
+ $tt += 1;
257
+ }
258
+ }
259
+ }
260
+
261
+ /* ... Replace Beginning/Middle/End random Ads ... */
262
+ if( strpos($content, '<!--'.$cusrnd.'-->')!==false && ($showall || !$ismany) ) {
263
+ $tcx = count($AdsId);
264
+ $tcy = substr_count($content, '<!--'.$cusrnd.'-->');
265
+ for( $i=$tcx; $i<=$tcy-1; $i++ ) {
266
+ array_push($AdsId, -1);
267
+ }
268
+ shuffle($AdsId);
269
+ for( $i=1; $i<=$tcy; $i++ ) {
270
+ $content = quick_adsense_2_replace_ads( $content, $cusrnd, $AdsId[0] ); $AdsId = quick_adsense_2_del_element($AdsId, 0) ;
271
+ $ShownAds += 1; if( $ShownAds >= $AdsToShow || !count($AdsId) ){ $content = quick_adsense_2_clean_tags($content); return $content; };
272
+ }
273
+ }
274
+
275
+ /* ... Replace RndAds ... */
276
+ if( strpos($content, '<!--RndAds-->')!==false && ($showall || !$ismany) ) {
277
+ $AdsIdTmp = array();
278
+ shuffle($AdsId);
279
+ for( $i=1; $i<=$AdsToShow-$ShownAds; $i++ ) {
280
+ if( $i <= count($AdsId) ) {
281
+ array_push($AdsIdTmp, $AdsId[$i-1]);
282
+ }
283
+ }
284
+ $tcx = count($AdsIdTmp);
285
+ $tcy = substr_count($content, '<!--RndAds-->');
286
+ for( $i=$tcx; $i<=$tcy-1; $i++ ) {
287
+ array_push($AdsIdTmp, -1);
288
+ }
289
+ shuffle($AdsIdTmp);
290
+ for( $i=1; $i<=$tcy; $i++ ) {
291
+ $tmp = $AdsIdTmp[0];
292
+ $content = quick_adsense_2_replace_ads( $content, 'RndAds', $AdsIdTmp[0] ); $AdsIdTmp = quick_adsense_2_del_element($AdsIdTmp, 0) ;
293
+ if($tmp != -1){$ShownAds += 1;}; if( $ShownAds >= $AdsToShow || !count($AdsIdTmp) ){ $content = quick_adsense_2_clean_tags($content); return $content; };
294
+ }
295
+ }
296
+
297
+ /* ... That's it. DONE :) ... */
298
+ $content = quick_adsense_2_clean_tags($content); return $content;
299
+ }
300
+
301
+ function quick_adsense_2_clean_tags($content, $trimonly = false) {
302
+ global $QData;
303
+ global $ShownAds;
304
+ global $AdsId;
305
+ global $beginend;
306
+ $tagnames = array('EmptyClear','RndAds','NoAds','OffDef','OffAds','OffWidget','OffBegin','OffMiddle','OffEnd','OffBfMore','OffAfLastPara','CusRnd');
307
+ for($i=1;$i<=$QData['Ads'];$i++) { array_push($tagnames, 'CusAds'.$i); array_push($tagnames, 'Ads'.$i); };
308
+ foreach ($tagnames as $tgn) {
309
+ if(strpos($content,'<!--'.$tgn.'-->')!==false || $tgn=='EmptyClear') {
310
+ if($trimonly) {
311
+ $content = str_replace('<p><!--'.$tgn.'--></p>', '<!--'.$tgn.'-->', $content);
312
+ }else{
313
+ $content = str_replace(array('<p><!--'.$tgn.'--></p>','<!--'.$tgn.'-->'), '', $content);
314
+ $content = str_replace("##QA-TP1##", "<p></p>", $content);
315
+ $content = str_replace("##QA-TP2##", "<p>&nbsp;</p>", $content);
316
+ }
317
+ }
318
+ }
319
+ if(!$trimonly && (is_single() || is_page()) ) {
320
+ $ShownAds = 0;
321
+ $AdsId = array();
322
+ $beginend = 0;
323
+ }
324
+ return $content;
325
+ }
326
+
327
+ function quick_adsense_2_replace_ads($content, $nme, $adn) {
328
+ if( strpos($content,'<!--'.$nme.'-->')===false ) { return $content; }
329
+ global $QData;
330
+ $options = quick_adsense_2_get_options_with_defaults();
331
+ if ($adn != -1) {
332
+ $arr = array('',
333
+ 'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
334
+ 'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
335
+ 'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
336
+ 'float:none;margin:0px;');
337
+ $adsalign = ((isset($options['AdsAlign'.$adn]))?$options['AdsAlign'.$adn]:'');
338
+ $adsmargin = ((isset($options['AdsMargin'.$adn]))?$options['AdsMargin'.$adn]:'');
339
+ $style = sprintf($arr[(int)$adsalign], $adsmargin);
340
+ $adscode = ((isset($options['AdsCode'.$adn]))?$options['AdsCode'.$adn]:'');
341
+ $adscode =
342
+ "\n".'<!-- '.$QData['Name'].' Wordpress Plugin: '.$QData['URI'].' -->'."\n".
343
+ '<div style="'.$style.'">'."\n".
344
+ $adscode."\n".
345
+ '</div>'."\n";
346
+ } else {
347
+ $adscode ='';
348
+ }
349
+ $cont = explode('<!--'.$nme.'-->', $content, 2);
350
+ return $cont[0].$adscode.$cont[1];
351
+ }
352
+
353
+ function quick_adsense_2_del_element($array, $idx) {
354
+ $copy = array();
355
+ for( $i=0; $i<count($array) ;$i++) {
356
+ if ( $idx != $i ) {
357
+ array_push($copy, $array[$i]);
358
+ }
359
+ }
360
+ return $copy;
361
+ }
362
+
363
+ add_action('init', 'quick_adsense_2_ads_widget_register');
364
+ function quick_adsense_2_ads_widget_register() {
365
+ global $QData;
366
+ $options = quick_adsense_2_get_options_with_defaults();
367
+ if (!function_exists('wp_register_sidebar_widget')) { return; };
368
+ for($i=1;$i<=$QData['AdsWid'];$i++) {
369
+ if(isset($options['WidCode'.$i]) && ($options['WidCode'.$i]!='')) {
370
+ $displaystr =
371
+ '$cont = get_the_content();'.
372
+ '$options = quick_adsense_2_get_options_with_defaults();'.
373
+ 'if( strpos($cont,"<!--OffAds-->")===false && strpos($cont,"<!--OffWidget-->")===false && !(is_home()&&$options["AppSide"]) ) {'.
374
+ 'extract($args);'.
375
+ '$title = ((isset($options["WidCode-title-'.$i.'"]))?$options["WidCode-title-'.$i.'"]:"");'.
376
+ '$codetxt = $options["WidCode'.$i.'"];'.
377
+ 'echo "\n"."<!-- Quick Adsense Wordpress Plugin: http://quickadsense.com/ -->"."\n";'.
378
+ 'echo $before_widget."\n";'.
379
+ 'if (!empty($title)) { '.
380
+ 'echo $before_title.$title.$after_title."\n"; '.
381
+ '};'.
382
+ 'echo $codetxt;'.
383
+ 'echo "\n".$after_widget;'.
384
+ '}';
385
+ $displaycall[$i] = create_function('$args', $displaystr);
386
+ $wadnam = sprintf($QData['AdsWidName'],$i);
387
+ $wadsid = sanitize_title(str_replace(array('(',')'),'',$wadnam));
388
+ wp_register_sidebar_widget($wadsid, $wadnam, $displaycall[$i], array('description' => 'Quick Adsense on Sidebar Widget'));
389
+ }
390
+ }
391
+ }
392
+ ?>
includes/migrate.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $QData;
3
+ $QData['AdsWid'] = 10;
4
+ $QData['Ads'] = 10;
5
+ $QData['Name'] = 'Quick Adsense';
6
+ $QData['Version'] = '1.9.4';
7
+ $QData['URI'] = 'http://quickadsense.com/';
8
+ $QData['AdsWidName'] = 'AdsWidget%d (Quick Adsense)';
9
+ $QData['Default'] = array(
10
+ 'AdsDisp' => '3',
11
+ 'BegnAds' => true,
12
+ 'BegnRnd' => '1',
13
+ 'EndiAds' => true,
14
+ 'EndiRnd' => '0',
15
+ 'MiddAds' => false,
16
+ 'MiddRnd' => '0',
17
+ 'MoreAds' => false,
18
+ 'MoreRnd' => '0',
19
+ 'LapaAds' => false,
20
+ 'LapaRnd' => '0',
21
+ 'Par1Ads' => false,
22
+ 'Par1Rnd' => '0',
23
+ 'Par1Nup' => '0',
24
+ 'Par1Con' => false,
25
+ 'Par2Ads' => false,
26
+ 'Par2Rnd' => '0',
27
+ 'Par2Nup' => '0',
28
+ 'Par2Con' => false,
29
+ 'Par3Ads' => false,
30
+ 'Par3Rnd' => '0',
31
+ 'Par3Nup' => '0',
32
+ 'Par3Con' => false,
33
+ 'Img1Ads' => false,
34
+ 'Img1Rnd' => '0',
35
+ 'Img1Nup' => '0',
36
+ 'Img1Con' => true,
37
+ 'AppPost' => true,
38
+ 'AppPage' => true,
39
+ 'AppHome' => false,
40
+ 'AppCate' => false,
41
+ 'AppArch' => false,
42
+ 'AppTags' => false,
43
+ 'AppMaxA' => false,
44
+ 'AppSide' => false,
45
+ 'AppLogg' => false,
46
+ 'QckTags' => true,
47
+ 'QckRnds' => false,
48
+ 'QckOffs' => false,
49
+ 'QckOfPs' => false
50
+ );
51
+
52
+ $QData['DefaultAdsOpt'] = array(
53
+ 'AdsMargin' => '10',
54
+ 'AdsAlign' => '2'
55
+ );
56
+ $QData['DefaultAdsName'] = array();
57
+
58
+ for($i = 1; $i <= $QData['Ads']; $i++) {
59
+ array_push($QData['DefaultAdsName'], 'AdsCode'.$i);
60
+ array_push($QData['DefaultAdsName'], 'AdsAlign'.$i);
61
+ array_push($QData['DefaultAdsName'], 'AdsMargin'.$i);
62
+ };
63
+
64
+ for($i = 1; $i <= $QData['AdsWid']; $i++) {
65
+ array_push($QData['DefaultAdsName'], 'WidCode'.$i);
66
+ };
67
+
68
+
69
+ function quick_adsense_2_get_options_with_defaults() {
70
+ global $QData;
71
+ //delete_option('quick_adsense_2_options');
72
+ $options = get_option('quick_adsense_2_options');
73
+ if(!is_array($options) || (count($options) < 1)) {
74
+ $oldData = get_option('AdsDisp');
75
+ if(!isset($oldData) && is_bool($oldData)) {
76
+ $options = array (
77
+ 'AdsDisp' => $QData['Default']['AdsDisp'],
78
+ 'BegnAds' => $QData['Default']['BegnAds'],
79
+ 'BegnRnd' => $QData['Default']['BegnRnd'],
80
+ 'MiddAds' => $QData['Default']['MiddAds'],
81
+ 'MiddRnd' => $QData['Default']['MiddRnd'],
82
+ 'EndiAds' => $QData['Default']['EndiAds'],
83
+ 'EndiRnd' => $QData['Default']['EndiRnd'],
84
+ 'MoreAds' => $QData['Default']['MoreAds'],
85
+ 'MoreRnd' => $QData['Default']['MoreRnd'],
86
+ 'LapaAds' => $QData['Default']['LapaAds'],
87
+ 'LapaRnd' => $QData['Default']['LapaRnd'],
88
+ 'Par1Ads' => $QData['Default']['Par1Ads'],
89
+ 'Par1Rnd' => $QData['Default']['Par1Rnd'],
90
+ 'Par1Nup' => $QData['Default']['Par1Nup'],
91
+ 'Par1Con' => $QData['Default']['Par1Con'],
92
+ 'Par2Ads' => $QData['Default']['Par2Ads'],
93
+ 'Par2Rnd' => $QData['Default']['Par2Rnd'],
94
+ 'Par2Nup' => $QData['Default']['Par2Nup'],
95
+ 'Par2Con' => $QData['Default']['Par2Con'],
96
+ 'Par3Ads' => $QData['Default']['Par3Ads'],
97
+ 'Par3Rnd' => $QData['Default']['Par3Rnd'],
98
+ 'Par3Nup' => $QData['Default']['Par3Nup'],
99
+ 'Par3Con' => $QData['Default']['Par3Con'],
100
+ 'Img1Ads' => $QData['Default']['Img1Ads'],
101
+ 'Img1Rnd' => $QData['Default']['Img1Rnd'],
102
+ 'Img1Nup' => $QData['Default']['Img1Nup'],
103
+ 'Img1Con' => $QData['Default']['Img1Con'],
104
+ 'AppPost' => $QData['Default']['AppPost'],
105
+ 'AppPage' => $QData['Default']['AppPage'],
106
+ 'AppHome' => $QData['Default']['AppHome'],
107
+ 'AppCate' => $QData['Default']['AppCate'],
108
+ 'AppArch' => $QData['Default']['AppArch'],
109
+ 'AppTags' => $QData['Default']['AppTags'],
110
+ 'AppMaxA' => $QData['Default']['AppMaxA'],
111
+ 'AppSide' => $QData['Default']['AppSide'],
112
+ 'AppLogg' => $QData['Default']['AppLogg'],
113
+ 'QckTags' => $QData['Default']['QckTags'],
114
+ 'QckRnds' => $QData['Default']['QckRnds'],
115
+ 'QckOffs' => $QData['Default']['QckOffs'],
116
+ 'QckOfPs' => $QData['Default']['QckOfPs'],
117
+ 'AdsCode1' => '',
118
+ 'AdsAlign1' => 2,
119
+ 'AdsMargin1' => 10,
120
+ 'AdsCode2' => '',
121
+ 'AdsAlign2' => 2,
122
+ 'AdsMargin2' => 10,
123
+ 'AdsCode3' => '',
124
+ 'AdsAlign3' => 2,
125
+ 'AdsMargin3' => 10,
126
+ 'AdsCode4' => '',
127
+ 'AdsAlign4' => 2,
128
+ 'AdsMargin4' => 10,
129
+ 'AdsCode5' => '',
130
+ 'AdsAlign5' => 2,
131
+ 'AdsMargin5' => 10,
132
+ 'AdsCode6' => '',
133
+ 'AdsAlign6' => 2,
134
+ 'AdsMargin6' => 10,
135
+ 'AdsCode7' => '',
136
+ 'AdsAlign7' => 2,
137
+ 'AdsMargin7' => 10,
138
+ 'AdsCode8' => '',
139
+ 'AdsAlign8' => 2,
140
+ 'AdsMargin8' => 10,
141
+ 'AdsCode9' => '',
142
+ 'AdsAlign9' => 2,
143
+ 'AdsMargin9' => 10,
144
+ 'AdsCode10' => '',
145
+ 'AdsAlign10' => 2,
146
+ 'AdsMargin10' => 10,
147
+ 'WidCode1' => '',
148
+ 'WidCode2' => '',
149
+ 'WidCode3' => '',
150
+ 'WidCode4' => '',
151
+ 'WidCode5' => '',
152
+ 'WidCode6' => '',
153
+ 'WidCode7' => '',
154
+ 'WidCode8' => '',
155
+ 'WidCode9' => '',
156
+ 'WidCode10' => ''
157
+ );
158
+ } else {
159
+ $options = array (
160
+ 'AdsDisp' => get_option('AdsDisp'),
161
+ 'BegnAds' => get_option('BegnAds'),
162
+ 'BegnRnd' => get_option('BegnRnd'),
163
+ 'MiddAds' => get_option('MiddAds'),
164
+ 'MiddRnd' => get_option('MiddRnd'),
165
+ 'EndiAds' => get_option('EndiAds'),
166
+ 'EndiRnd' => get_option('EndiRnd'),
167
+ 'MoreAds' => get_option('MoreAds'),
168
+ 'MoreRnd' => get_option('MoreRnd'),
169
+ 'LapaAds' => get_option('LapaAds'),
170
+ 'LapaRnd' => get_option('LapaRnd'),
171
+ 'Par1Ads' => get_option('Par1Ads'),
172
+ 'Par1Rnd' => get_option('Par1Rnd'),
173
+ 'Par1Nup' => get_option('Par1Nup'),
174
+ 'Par1Con' => get_option('Par1Con'),
175
+ 'Par2Ads' => get_option('Par2Ads'),
176
+ 'Par2Rnd' => get_option('Par2Rnd'),
177
+ 'Par2Nup' => get_option('Par2Nup'),
178
+ 'Par2Con' => get_option('Par2Con'),
179
+ 'Par3Ads' => get_option('Par3Ads'),
180
+ 'Par3Rnd' => get_option('Par3Rnd'),
181
+ 'Par3Nup' => get_option('Par3Nup'),
182
+ 'Par3Con' => get_option('Par3Con'),
183
+ 'Img1Ads' => get_option('Img1Ads'),
184
+ 'Img1Rnd' => get_option('Img1Rnd'),
185
+ 'Img1Nup' => get_option('Img1Nup'),
186
+ 'Img1Con' => get_option('Img1Con'),
187
+ 'AppPost' => get_option('AppPost'),
188
+ 'AppPage' => get_option('AppPage'),
189
+ 'AppHome' => get_option('AppHome'),
190
+ 'AppCate' => get_option('AppCate'),
191
+ 'AppArch' => get_option('AppArch'),
192
+ 'AppTags' => get_option('AppTags'),
193
+ 'AppMaxA' => get_option('AppMaxA'),
194
+ 'AppSide' => get_option('AppSide'),
195
+ 'AppLogg' => get_option('AppLogg'),
196
+ 'QckTags' => get_option('QckTags'),
197
+ 'QckRnds' => get_option('QckRnds'),
198
+ 'QckOffs' => get_option('QckOffs'),
199
+ 'QckOfPs' => get_option('QckOfPs'),
200
+ 'AdsCode1' => get_option('AdsCode1'),
201
+ 'AdsAlign1' => get_option('AdsAlign1'),
202
+ 'AdsMargin1' => get_option('AdsMargin1'),
203
+ 'AdsCode2' => get_option('AdsCode2'),
204
+ 'AdsAlign2' => get_option('AdsAlign2'),
205
+ 'AdsMargin2' => get_option('AdsMargin2'),
206
+ 'AdsCode3' => get_option('AdsCode3'),
207
+ 'AdsAlign3' => get_option('AdsAlign3'),
208
+ 'AdsMargin3' => get_option('AdsMargin3'),
209
+ 'AdsCode4' => get_option('AdsCode4'),
210
+ 'AdsAlign4' => get_option('AdsAlign4'),
211
+ 'AdsMargin4' => get_option('AdsMargin4'),
212
+ 'AdsCode5' => get_option('AdsCode5'),
213
+ 'AdsAlign5' => get_option('AdsAlign5'),
214
+ 'AdsMargin5' => get_option('AdsMargin5'),
215
+ 'AdsCode6' => get_option('AdsCode6'),
216
+ 'AdsAlign6' => get_option('AdsAlign6'),
217
+ 'AdsMargin6' => get_option('AdsMargin6'),
218
+ 'AdsCode7' => get_option('AdsCode7'),
219
+ 'AdsAlign7' => get_option('AdsAlign7'),
220
+ 'AdsMargin7' => get_option('AdsMargin7'),
221
+ 'AdsCode8' => get_option('AdsCode8'),
222
+ 'AdsAlign8' => get_option('AdsAlign8'),
223
+ 'AdsMargin8' => get_option('AdsMargin8'),
224
+ 'AdsCode9' => get_option('AdsCode9'),
225
+ 'AdsAlign9' => get_option('AdsAlign9'),
226
+ 'AdsMargin9' => get_option('AdsMargin9'),
227
+ 'AdsCode10' => get_option('AdsCode10'),
228
+ 'AdsAlign10' => get_option('AdsAlign10'),
229
+ 'AdsMargin10' => get_option('AdsMargin10'),
230
+ 'WidCode1' => get_option('WidCode1'),
231
+ 'WidCode2' => get_option('WidCode2'),
232
+ 'WidCode3' => get_option('WidCode3'),
233
+ 'WidCode4' => get_option('WidCode4'),
234
+ 'WidCode5' => get_option('WidCode5'),
235
+ 'WidCode6' => get_option('WidCode6'),
236
+ 'WidCode7' => get_option('WidCode7'),
237
+ 'WidCode8' => get_option('WidCode8'),
238
+ 'WidCode9' => get_option('WidCode9'),
239
+ 'WidCode10' => get_option('WidCode10')
240
+ );
241
+ }
242
+ delete_option('AdsDisp');
243
+ update_option('quick_adsense_2_options', $options);
244
+ }
245
+ return $options;
246
+ }
247
+ ?>
includes/settings.php ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ add_action('admin_menu', 'quick_adsense_2_add_menu');
3
+ function quick_adsense_2_add_menu() {
4
+ $page = add_options_page('Quick Adsense Options', 'Quick Adsense', 'manage_options', 'quick-adsense-2', 'quick_adsense_2_settings_page');
5
+ }
6
+
7
+ add_action('admin_init', 'quick_adsense_2_admin_init');
8
+ function quick_adsense_2_admin_init() {
9
+ register_setting('quick_adsense_2_options', 'quick_adsense_2_options', 'quick_adsense_2_validate');
10
+ add_settings_section('quick_adsense_2_main', '', 'quick_adsense_2_section_text', 'quick-adsense-2');
11
+ }
12
+
13
+ add_filter('plugin_action_links', 'quick_adsense_2_plugin_action_links', 10, 2);
14
+ function quick_adsense_2_plugin_action_links($links, $file) {
15
+ if($file == 'quick-adsense/quick-adsense.php') {
16
+ array_unshift($links,'<a href="options-general.php?page=quick-adsense-2">'.__('Setting').'</a>');
17
+ }
18
+ return $links;
19
+ }
20
+
21
+ function quick_adsense_2_settings_page() { ?>
22
+ <div class="wrap">
23
+ <h2>Quick Adsense Setting <span style="font-size: 9pt; font-style: italic">( Version 2.0 )</span></h2>
24
+ <form method="post" action="options.php" name="wp_auto_commenter_form">
25
+ <?php settings_fields('quick_adsense_2_options'); ?>
26
+ <?php do_settings_sections('quick-adsense-2'); ?>
27
+ <?php submit_button(); ?>
28
+ </form>
29
+ </div>
30
+ <?php
31
+ }
32
+
33
+ function quick_adsense_2_section_text() {
34
+ global $QData;
35
+ $options = quick_adsense_2_get_options_with_defaults();
36
+ ?>
37
+ <script type="text/javascript">
38
+ function defaultoptions() {
39
+ document.getElementById("DisTot<?php echo($QData['Default']['AdsDisp']) ?>").selected = true;
40
+ document.getElementById("BegnAds").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['BegnAds'])) ?>;
41
+ document.getElementById("BegnRnd").selectedIndex = <?php echo($QData['Default']['BegnRnd']) ?>;
42
+ document.getElementById("MiddAds").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['MiddAds'])) ?>;
43
+ document.getElementById("MiddRnd").selectedIndex = <?php echo($QData['Default']['MiddRnd']) ?>;
44
+ document.getElementById("EndiAds").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['EndiAds'])) ?>;
45
+ document.getElementById("EndiRnd").selectedIndex = <?php echo($QData['Default']['EndiRnd']) ?>;
46
+ document.getElementById("MoreAds").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['MoreAds'])) ?>;
47
+ document.getElementById("MoreRnd").selectedIndex = <?php echo($QData['Default']['MoreRnd']) ?>;
48
+ document.getElementById("LapaAds").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['LapaAds'])) ?>;
49
+ document.getElementById("LapaRnd").selectedIndex = <?php echo($QData['Default']['LapaRnd']) ?>;
50
+ <?php for ($j=1;$j<=3;$j++) { ?>
51
+ document.getElementById("Par<?php echo $j; ?>Ads").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['Par'.$j.'Ads'])) ?>;
52
+ document.getElementById("Par<?php echo $j; ?>Rnd").selectedIndex = <?php echo($QData['Default']['Par'.$j.'Rnd']) ?>;
53
+ document.getElementById("Par<?php echo $j; ?>Nup").selectedIndex = <?php echo($QData['Default']['Par'.$j.'Nup']) ?>;
54
+ document.getElementById("Par<?php echo $j; ?>Con").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['Par'.$j.'Con'])) ?>;
55
+ <?php } ?>
56
+ document.getElementById("Img1Ads").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['Img1Ads'])) ?>;
57
+ document.getElementById("Img1Rnd").selectedIndex = <?php echo($QData['Default']['Img1Rnd']) ?>;
58
+ document.getElementById("Img1Nup").selectedIndex = <?php echo($QData['Default']['Img1Nup']) ?>;
59
+ document.getElementById("Img1Con").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['Img1Con'])) ?>;
60
+ document.getElementById("AppHome").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppHome'])) ?>;
61
+ document.getElementById("AppPost").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppPost'])) ?>;
62
+ document.getElementById("AppPage").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppPage'])) ?>;
63
+ document.getElementById("AppCate").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppCate'])) ?>;
64
+ document.getElementById("AppArch").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppArch'])) ?>;
65
+ document.getElementById("AppTags").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppTags'])) ?>;
66
+ document.getElementById("AppMaxA").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppMaxA'])) ?>;
67
+ document.getElementById("AppSide").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppSide'])) ?>;
68
+ document.getElementById("AppLogg").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['AppLogg'])) ?>;
69
+ document.getElementById("QckTags").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['QckTags'])) ?>;
70
+ document.getElementById("QckRnds").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['QckRnds'])) ?>;
71
+ document.getElementById("QckOffs").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['QckOffs'])) ?>;
72
+ document.getElementById("QckOfPs").checked = <?php echo(quick_adsense_2_truefalse($QData['Default']['QckOfPs'])) ?>;
73
+ for(i=1;i<=<?php echo($QData['Ads']) ?>;i++){
74
+ tp=document.getElementById("AdsCode"+i.toString()).innerHTML;
75
+ if(tp==''){
76
+ document.getElementById("AdsMargin"+i.toString()).value = "<?php echo($QData['DefaultAdsOpt']['AdsMargin']) ?>";
77
+ document.getElementById("OptAgn"+i.toString()+"<?php echo($QData['DefaultAdsOpt']['AdsAlign']) ?>").selected = true;
78
+ }
79
+ }
80
+ deftcheckinfo();
81
+ }
82
+
83
+ function selectinfo(ts) {
84
+ if (ts.selectedIndex == 0) { return; }
85
+ cek = new Array(
86
+ document.getElementById('BegnRnd'),
87
+ document.getElementById('MiddRnd'),
88
+ document.getElementById('EndiRnd'),
89
+ document.getElementById('MoreRnd'),
90
+ document.getElementById('LapaRnd'),
91
+ document.getElementById('Par1Rnd'),
92
+ document.getElementById('Par2Rnd'),
93
+ document.getElementById('Par3Rnd'),
94
+ document.getElementById('Img1Rnd') );
95
+ for (i=0;i<cek.length;i++) {
96
+ if (ts != cek[i] && ts.selectedIndex == cek[i].selectedIndex) {
97
+ cek[i].selectedIndex = 0;
98
+ }
99
+ }
100
+ }
101
+
102
+ function checkinfo1(selnme,ts) {
103
+ document.getElementById(selnme).disabled=!ts.checked;
104
+ }
105
+
106
+ function checkinfo2(ts,selnm1,selnm2,selnm3,selnm4) {
107
+ if(selnm1){document.getElementById(selnm1).disabled=!ts.checked};
108
+ if(selnm2){document.getElementById(selnm2).disabled=!ts.checked};
109
+ if(selnm3){document.getElementById(selnm3).disabled=!ts.checked};
110
+ }
111
+
112
+ function deftcheckinfo() {
113
+ checkinfo1('BegnRnd',document.getElementById('BegnAds'));
114
+ checkinfo1('MiddRnd',document.getElementById('MiddAds'));
115
+ checkinfo1('EndiRnd',document.getElementById('EndiAds'));
116
+ checkinfo1('MoreRnd',document.getElementById('MoreAds'));
117
+ checkinfo1('LapaRnd',document.getElementById('LapaAds'));
118
+ for (i=1;i<=3;i++) {
119
+ checkinfo2(document.getElementById('Par'+i+'Ads'),'Par'+i+'Rnd','Par'+i+'Nup','Par'+i+'Con');
120
+ }
121
+ checkinfo2(document.getElementById('Img1Ads'),'Img1Rnd','Img1Nup','Img1Con');
122
+ }
123
+ </script>
124
+ <h3 style="font-size: 120%"><?php _e('Options'); ?></h3>
125
+ <table border="0" cellspacing="0" cellpadding="0">
126
+ <tr valign="top">
127
+ <td style="width: 110px"><?php _e('Adsense :'); ?></td>
128
+ <td><?php _e('Place up to '); ?>
129
+ <?php
130
+ if(!$options['AdsDisp']&&is_bool($options['AdsDisp'])) {
131
+ $options['AdsDisp'] = $QData['Default']['AdsDisp'];
132
+ }
133
+ ?>
134
+ <select name="quick_adsense_2_options[AdsDisp]" style="width: 50px; font-weight: bold;">
135
+ <?php for ($i = 0; $i <= (int)$QData['Ads']; $i++) { ?>
136
+ <option id="DisTot<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['AdsDisp']) && $options['AdsDisp']==(string)$i){echo('selected');} ?>><?php echo $i; ?></option>
137
+ <?php } ?>
138
+ </select><?php _e(' Ads on a page.'); ?>
139
+ </td>
140
+ </tr>
141
+ <tr valign="top">
142
+ <td style="width:110px"><?php _e('Position :<br/>(Default)'); ?></td>
143
+ <td>
144
+ <input type="checkbox" id="BegnAds" name="quick_adsense_2_options[BegnAds]" value="true" <?php if(isset($options['BegnAds']) && ($options['BegnAds'] == 'true')){echo('checked');} ?> onchange="checkinfo1('BegnRnd',this)" />
145
+ <?php _e('Assign') ; ?>
146
+ <select id="BegnRnd" name="quick_adsense_2_options[BegnRnd]" onchange="selectinfo(this)">
147
+ <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
148
+ <option id="OptBegn<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['BegnRnd']) && $options['BegnRnd']==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
149
+ <?php } ?>
150
+ </select>
151
+ <?php _e('to <b>Beginning of Post</b>') ?><br/>
152
+
153
+ <input type="checkbox" id="MiddAds" name="quick_adsense_2_options[MiddAds]" value="false" <?php if(isset($options['MiddAds']) && ($options['MiddAds'] == 'false')){echo('checked');} ?> onchange="checkinfo1('MiddRnd',this)" />
154
+ <?php _e('Assign') ; ?>
155
+ <select id="MiddRnd" name="quick_adsense_2_options[MiddRnd]" onchange="selectinfo(this)">
156
+ <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
157
+ <option id="OptMidd<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['MiddRnd']) && $options['MiddRnd']==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
158
+ <?php } ?>
159
+ </select>
160
+ <?php _e('to <b>Middle of Post</b>') ?><br/>
161
+
162
+ <input type="checkbox" id="EndiAds" name="quick_adsense_2_options[EndiAds]" value="false" <?php if(isset($options['EndiAds']) && ($options['EndiAds'] == 'false')){echo('checked');} ?> onchange="checkinfo1('EndiRnd',this)" />
163
+ <?php _e('Assign') ; ?>
164
+ <select id="EndiRnd" name="quick_adsense_2_options[EndiRnd]" onchange="selectinfo(this)">
165
+ <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
166
+ <option id="OptEndi<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['EndiRnd']) && $options['EndiRnd']==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
167
+ <?php } ?>
168
+ </select>
169
+ <?php _e('to <b>End of Post</b>') ?><br/>
170
+
171
+ <input type="checkbox" id="MoreAds" name="quick_adsense_2_options[MoreAds]" value="false" <?php if(isset($options['MoreAds']) && ($options['MoreAds'] == 'false')){echo('checked');} ?> onchange="checkinfo1('MoreRnd',this)" />
172
+ <?php _e('Assign') ; ?>
173
+ <select id="MoreRnd" name="quick_adsense_2_options[MoreRnd]" onchange="selectinfo(this)">
174
+ <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
175
+ <option id="OptMore<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['MoreRnd']) && $options['MoreRnd']==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
176
+ <?php } ?>
177
+ </select>
178
+ <?php _e('right after <b>the') ?>
179
+ <span style="font-family:Courier New,Courier,Fixed;">&lt;!--more--&gt;</span> <?php _e('tag') ?></b><br/>
180
+
181
+ <input type="checkbox" id="LapaAds" name="quick_adsense_2_options[LapaAds]" value="false" <?php if(isset($options['LapaAds']) && ($options['LapaAds'] == 'false')){echo('checked');} ?> onchange="checkinfo1('LapaRnd',this)" />
182
+ <?php _e('Assign') ; ?>
183
+ <select id="LapaRnd" name="quick_adsense_2_options[LapaRnd]" onchange="selectinfo(this)">
184
+ <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
185
+ <option id="OptLapa<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['LapaRnd']) && $options['LapaRnd']==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
186
+ <?php } ?>
187
+ </select>
188
+ <?php _e('right before <b>the last Paragraph</b>') ?><span style="color:#a00;"> <b>(New)</b></span><br/>
189
+
190
+ <?php for($j = 1; $j <= 3; $j++) { ?>
191
+ <input type="checkbox" id="Par<?php echo $j; ?>Ads" name="quick_adsense_2_options[Par<?php echo $j; ?>Ads]" value="false" <?php if(isset($options['Par'.$j.'Ads']) && ($options['Par'.$j.'Ads'] == 'false')){echo('checked');} ?> onchange="checkinfo2(this,'Par<?php echo $j; ?>Rnd','Par<?php echo $j; ?>Nup','Par<?php echo $j; ?>Con')" />
192
+ <?php _e('Assign') ; ?>
193
+ <select id="Par<?php echo $j; ?>Rnd" name="quick_adsense_2_options[Par<?php echo $j; ?>Rnd]" onchange="selectinfo(this)">
194
+ <?php for ($i = 0; $i <= $QData['Ads']; $i++) { ?>
195
+ <option id="OptPar<?php echo $j; ?><?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['Par'.$j.'Rnd']) && $options['Par'.$j.'Rnd']==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
196
+ <?php } ?>
197
+ </select>
198
+
199
+ <?php _e('<b>After Paragraph</b> ') ?>
200
+ <select id="Par<?php echo $j; ?>Nup" name="quick_adsense_2_options[Par<?php echo $j; ?>Nup]">
201
+ <?php for ($i=1;$i<=50;$i++) { ?>
202
+ <option id="Opt<?php echo $j; ?>Nu<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['Par'.$j.'Nup']) && $options['Par'.$j.'Nup']==(string)$i){echo('selected');} ?>><?php echo $i; ?></option>
203
+ <?php } ?>
204
+ </select> &rarr;
205
+
206
+ <input type="checkbox" id="Par<?php echo $j; ?>Con" name="quick_adsense_2_options[Par<?php echo $j; ?>Con]" value="false" <?php if(isset($options['Par'.$j.'Con']) && ($options['Par'.$j.'Con'] == 'false')){echo('checked');} ?> />
207
+ <?php _e('to <b>End of Post</b> if fewer paragraphs are found.') ; ?><br/>
208
+ <?php } ?>
209
+
210
+ <input type="checkbox" id="Img1Ads" name="quick_adsense_2_options[Img1Ads]" value="false" <?php if(isset($options['Img1Ads']) && ($options['Img1Ads'] == 'false')){echo('checked');} ?> onchange="checkinfo2(this,'Img1Rnd','Img1Nup','Img1Con')" />
211
+ <?php _e('Assign') ; ?>
212
+ <select id="Img1Rnd" name="quick_adsense_2_options[Img1Rnd]" onchange="selectinfo(this)">
213
+ <?php for ($i = 0; $i <= $QData['Ads']; $i++) { ?>
214
+ <option id="OptImg1<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['Img1Rnd']) && $options['Img1Rnd']==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
215
+ <?php } ?>
216
+ </select>
217
+ <?php _e('<b>After Image</b> ') ?>
218
+ <select id="Img1Nup" name="quick_adsense_2_options[Img1Nup]">
219
+ <?php for ($i = 1; $i <= 50; $i++) { ?>
220
+ <option id="Opt1Im<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if(isset($options['Img1Nup']) && $options['Img1Nup']==(string)$i){echo('selected');} ?>><?php echo $i; ?></option>
221
+ <?php } ?>
222
+ </select> &rarr;
223
+ <input type="checkbox" id="Img1Con" name="quick_adsense_2_options[Img1Con]" value="false" <?php if(isset($options['Img1Con']) && ($options['Img1Con'] == 'false')){echo('checked');} ?> />
224
+ <?php _e('after <b>Image&#39;s outer</b>'); ?>
225
+ <b><span style="font-family:Courier New,Courier,Fixed;"> &lt;div&gt; wp-caption</span></b> if any.<span style="color:#a00;"> <b>(New)</b></span><br/><br/>
226
+ <script type="text/javascript">deftcheckinfo();</script>
227
+ </td>
228
+ </tr>
229
+ <tr valign="top">
230
+ <td style="width:110px"><?php _e('Appearance :'); ?></td>
231
+ <td>
232
+ <span>[ </span>
233
+ <input type="checkbox" id="AppPost" name="quick_adsense_2_options[AppPost]" value="true" <?php if(isset($options['AppPost']) && ($options['AppPost'] == 'true')){echo('checked');} ?> /> <?php _e('Posts'); ?>
234
+ <input type="checkbox" id="AppPage" name="quick_adsense_2_options[AppPage]" value="true" <?php if(isset($options['AppPage']) && ($options['AppPage'] == 'true')){echo('checked');} ?> /> <?php _e('Pages'); ?>
235
+ <span> ]</span><br/>
236
+ <span>[ </span>
237
+ <input type="checkbox" id="AppHome" name="quick_adsense_2_options[AppHome]" value="true" <?php if(isset($options['AppHome']) && ($options['AppHome'] == 'true')){echo('checked');} ?> /> <?php _e('Homepage'); ?>
238
+ <input type="checkbox" id="AppCate" name="quick_adsense_2_options[AppCate]" value="true" <?php if(isset($options['AppCate']) && ($options['AppCate'] == 'true')){echo('checked');} ?> /> <?php _e('Categories'); ?>
239
+ <input type="checkbox" id="AppArch" name="quick_adsense_2_options[AppArch]" value="true" <?php if(isset($options['AppArch']) && ($options['AppArch'] == 'true')){echo('checked');} ?> /> <?php _e('Archives'); ?>
240
+ <input type="checkbox" id="AppTags" name="quick_adsense_2_options[AppTags]" value="true" <?php if(isset($options['AppTags']) && ($options['AppTags'] == 'true')){echo('checked');} ?> /> <?php _e('Tags'); ?>
241
+ <span> ] &rarr; </span>
242
+ <input type="checkbox" id="AppMaxA" name="quick_adsense_2_options[AppMaxA]" value="true" <?php if(isset($options['AppMaxA']) && ($options['AppMaxA'] == 'true')){echo('checked');} ?> /> <?php _e('Place all possible Ads on these pages.'); ?><br/>
243
+ <span>[ </span>
244
+ <input type="checkbox" id="AppSide" name="quick_adsense_2_options[AppSide]" value="true" <?php if(isset($options['AppSide']) && ($options['AppSide'] == 'true')){echo('checked');} ?> /> <?php _e('Disable AdsWidget on Homepage'); ?>
245
+ <span> ]</span><br/>
246
+ <span>[ </span>
247
+ <input type="checkbox" id="AppLogg" name="quick_adsense_2_options[AppLogg]" value="true" <?php if(isset($options['AppLogg']) && ($options['AppLogg'] == 'true')){echo('checked');} ?> /> <?php _e('Hide Ads when user is logged in to Wordpress'); ?>
248
+ <span> ]</span><br/><br/>
249
+ </td>
250
+ </tr>
251
+ <tr valign="top">
252
+ <td style="width:110px"><?php _e('Quicktag :'); ?></td>
253
+ <td>
254
+ <span style="display:block;font-style:normal;padding-bottom:0px"><?php _e('Insert Ads into a post, on-the-fly :'); ?></span>
255
+ <ol style="margin-top:5px;">
256
+ <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--Ads1--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--Ads2--&gt;</span>, etc. into a post to show the <b>Particular Ads</b> at specific location.'); ?></li>
257
+ <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--RndAds--&gt;</span> (or more) into a post to show the <b>Random Ads</b> at specific location.'); ?></li>
258
+ </ol>
259
+ <span style="display:block;font-style:normal;padding-bottom:0px"><?php _e('Disable Ads in a post, on-the-fly :'); ?></span>
260
+ <ol style="margin-top:5px;">
261
+ <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--NoAds--&gt;</span> to <b>disable all Ads</b> in a post.'); ?><span class="description" style="font-style:italic"><?php _e(' (does not affect Ads on Sidebar)'); ?></span></li>
262
+ <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffDef--&gt;</span> to <b>disable the default positioned Ads</b>, and use <span style="font-family:Courier New,Courier,Fixed;">&lt;!--Ads1--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;">&lt;!--Ads2--&gt;</span>, etc. to insert Ads.'); ?><span class="description" style="font-style:italic"><?php _e(' (does not affect Ads on Sidebar)'); ?></span></li>
263
+ <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffWidget--&gt;</span> to <b>disable all Ads on Sidebar</b>.'); ?><span style="color:#a00;"> <b>(New)</b></span></li>
264
+ <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBegin--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffMiddle--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffEnd--&gt;</span> to <b>disable Ads at Beginning, Middle</b> or <b>End of Post</b>.'); ?><span style="color:#a00;"> <b>(New)</b></span></li>
265
+ <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffAfMore--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBfLastPara--&gt;</span> to <b>disable Ads right after the <span style="font-family:Courier New,Courier,Fixed;">&lt;!--more--&gt;</span> tag</b>, or <b>right before the last Paragraph</b>.'); ?><span style="color:#a00;"> <b>(New)</b></span></li>
266
+ </ol>
267
+ [ <input type="checkbox" id="QckTags" name="quick_adsense_2_options[QckTags]" value="true" <?php if(isset($options['QckTags']) && ($options['QckTags'] == 'true')){echo('checked');} ?> /> <?php _e('Show Quicktag Buttons on the HTML Edit Post SubPanel'); ?> ]<br/>
268
+ [ <input type="checkbox" id="QckRnds" name="quick_adsense_2_options[QckRnds]" value="true" <?php if(isset($options['QckRnds']) && ($options['QckRnds'] == 'true')){echo('checked');} ?> /> <?php _e('Hide <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--RndAds--&gt;</span> from Quicktag Buttons'); ?> ]<br/>
269
+ [ <input type="checkbox" id="QckOffs" name="quick_adsense_2_options[QckOffs]" value="true" <?php if(isset($options['QckOffs']) && ($options['QckOffs'] == 'true')){echo('checked');} ?> /> <?php _e('Hide <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--NoAds--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffDef--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffWidget--&gt;</span> from Quicktag Buttons'); ?> ]<br/>
270
+ [ <input type="checkbox" id="QckOfPs" name="quick_adsense_2_options[QckOfPs]" value="true" <?php if(isset($options['QckOfPs']) && ($options['QckOfPs'] == 'true')){echo('checked');} ?> /> <?php _e('Hide <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBegin--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffMiddle--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffEnd--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffAfMore--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBfLastPara--&gt;</span> from Quicktag Buttons'); ?> ]<br/>
271
+ <span class="description" style="display:block;font-style:italic;padding-top:10px"><?php _e('Tags can be inserted into a post via the additional Quicktag Buttons at the HTML Edit Post SubPanel.'); ?></span><br/>
272
+ </td>
273
+ </tr>
274
+ <tr valign="top">
275
+ <td style="width:110px"><?php _e('Infomation :'); ?></td>
276
+ <td>
277
+ <span><?php echo(__('A link from your blog to <a href="http://quickadsense.com/" target="_blank">http://quickadsense.com/</a> would be appreciated.')); ?></span>
278
+ </td>
279
+ </tr>
280
+ </table>
281
+ <p style="margin-top:20px">( <a href="javascript:defaultoptions()"><?php _e('Load Default Setting') ?></a> )<br/><br/></p>
282
+
283
+ <h3 style="font-size:120%;margin-bottom:5px"><?php _e('Adsense Codes'); ?></h3>
284
+ <p style="margin-top:0px"><span class="description"><?php _e('Paste up to <b>'.$QData['Ads'].' Ads codes</b> on Post Body as assigned above, and up to <b>'.$QData['AdsWid'].' Ads codes</b> on Sidebar Widget. Ads codes provided must <b>not</b> be identical, repeated codes may result the Ads not being display correctly. Ads will never displays more than once in a page.') ?></span></p>
285
+
286
+ <h4><?php _e('Ads on Post Body :'); ?></h4>
287
+ <table border="0" cellspacing="0" cellpadding="0">
288
+ <?php for ($i = 1; $i <= $QData['Ads']; $i++) { ?>
289
+ <tr valign="top">
290
+ <td align="left" style="width:110px">Ads<?php echo $i; ?> :</td>
291
+ <td align="left"><textarea style="margin:0 5px 3px 0" id="AdsCode<?php echo $i; ?>" name="quick_adsense_2_options[AdsCode<?php echo $i; ?>]" rows="3" cols="50"><?php echo htmlentities($options['AdsCode'.$i]); ?></textarea></td>
292
+ <td align="left">
293
+ <select name="quick_adsense_2_options[AdsAlign<?php echo $i; ?>]">
294
+ <option id="OptAgn<?php echo $i; ?>1" value="1" <?php if(isset($options['AdsAlign'.$i]) && $options['AdsAlign'.$i]=="1"){echo('selected');} ?>><?php _e('Left') ; ?></option>
295
+ <option id="OptAgn<?php echo $i; ?>2" value="2" <?php if(isset($options['AdsAlign'.$i]) && $options['AdsAlign'.$i]=="2"){echo('selected');} ?>><?php _e('Center') ; ?></option>
296
+ <option id="OptAgn<?php echo $i; ?>3" value="3" <?php if(isset($options['AdsAlign'.$i]) && $options['AdsAlign'.$i]=="3"){echo('selected');} ?>><?php _e('Right') ; ?></option>
297
+ <option id="OptAgn<?php echo $i; ?>4" value="4" <?php if(isset($options['AdsAlign'.$i]) && $options['AdsAlign'.$i]=="4"){echo('selected');} ?>><?php _e('None') ; ?></option>
298
+ </select>
299
+ <?php _e('alignment'); ?><br/>
300
+ <input style="width:35px;text-align:right;" id="AdsMargin<?php echo $i; ?>" name="quick_adsense_2_options[AdsMargin<?php echo $i; ?>]" value="<?php echo stripslashes(htmlspecialchars($options['AdsMargin'.$i])); ?>" />px <?php _e('margin'); ?><br/>
301
+ </td>
302
+ </tr>
303
+ <?php } ?>
304
+ </table>
305
+
306
+ <h4><?php _e('Ads on Sidebar Widget '); ?><span style="font-weight:normal">(<a href="widgets.php"><?php _e('Drag to Sidebar'); ?></a>)</span> :</h4>
307
+ <table border="0" cellspacing="0" cellpadding="0">
308
+ <?php
309
+ for ($i=1;$i<=$QData['AdsWid'];$i++) { ?>
310
+ <tr valign="top">
311
+ <td align="left" style="width:110px">AdsWidget<?php echo $i; ?> :</td>
312
+ <td align="left"><textarea style="margin:0 5px 3px 0" id="WidCode<?php echo $i; ?>" name="quick_adsense_2_options[WidCode<?php echo $i; ?>]" rows="3" cols="50"><?php echo htmlentities($options['WidCode'.$i]); ?></textarea></td>
313
+ </tr>
314
+ <?php } ?>
315
+ </table>
316
+ <?php
317
+ }
318
+
319
+ function quick_adsense_2_truefalse($arg) {
320
+ if($arg){
321
+ return 'true';
322
+ } else {
323
+ return 'false';
324
+ }
325
+ }
326
+
327
+ function quick_adsense_2_validate($input) {
328
+ return $input;
329
+ }
330
+ ?>
quick-adsense-admin.php DELETED
@@ -1,327 +0,0 @@
1
- <?php
2
-
3
- /* Copyright 2009-2013 BuySellAds [ http://quicksense.net/ ]
4
-
5
- This program is free software; you can redistribute it and/or modify
6
- it under the terms of the GNU General Public License as published by
7
- the Free Software Foundation; either version 2 of the License, or
8
- (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License
16
- along with this program; if not, write to the Free Software
17
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
- */
19
-
20
- ?>
21
-
22
- <?php
23
- global $QData;
24
- $dis = get_option('AdsDisp');if(!$dis&&is_bool($dis)){$dis=$QData['Default']['AdsDisp'];};
25
- $ra1 = get_option('BegnAds');
26
- $ra2 = get_option('BegnRnd');
27
- $rm1 = get_option('MiddAds');
28
- $rm2 = get_option('MiddRnd');
29
- $rb1 = get_option('EndiAds');
30
- $rb2 = get_option('EndiRnd');
31
- $rr1 = get_option('MoreAds');
32
- $rr2 = get_option('MoreRnd');
33
- $rp1 = get_option('LapaAds');
34
- $rp2 = get_option('LapaRnd');
35
- $rc = 3;
36
- for ($j=1;$j<=$rc;$j++) {
37
- $rc1[$j] = get_option('Par'.$j.'Ads');
38
- $rc2[$j] = get_option('Par'.$j.'Rnd');
39
- $rc3[$j] = get_option('Par'.$j.'Nup');
40
- $rc4[$j] = get_option('Par'.$j.'Con');
41
- }
42
- $rd1 = get_option('Img1Ads');
43
- $rd2 = get_option('Img1Rnd');
44
- $rd3 = get_option('Img1Nup');
45
- $rd4 = get_option('Img1Con');
46
- $aps = get_option('AppPost');
47
- $apg = get_option('AppPage');
48
- $ahm = get_option('AppHome');
49
- $act = get_option('AppCate');
50
- $aar = get_option('AppArch');
51
- $atg = get_option('AppTags');
52
- $amx = get_option('AppMaxA');
53
- $asd = get_option('AppSide');
54
- $lgg = get_option('AppLogg');
55
- $aqt = get_option('QckTags');
56
- $aqr = get_option('QckRnds');
57
- $aqf = get_option('QckOffs');
58
- $aqp = get_option('QckOfPs');
59
- $optionsupdate = '';
60
- foreach ($QData['Default'] as $key => $value) {
61
- $optionsupdate .= $key.',' ;
62
- }
63
- foreach ($QData['DefaultAdsName'] as $key => $value) {
64
- $optionsupdate .= $value.',' ;
65
- }
66
- $optionsupdate = substr($optionsupdate, 0, -1);
67
- function truefalse($arg) {
68
- if($arg){ return 'true';}else{ return 'false';}
69
- }
70
- ?>
71
-
72
- <script type="text/javascript">
73
- function defaultoptions() {
74
- document.getElementById("DisTot<?php echo($QData['Default']['AdsDisp']) ?>").selected = true;
75
- document.getElementById("BegnAds").checked = <?php echo(truefalse($QData['Default']['BegnAds'])) ?>;
76
- document.getElementById("BegnRnd").selectedIndex = <?php echo($QData['Default']['BegnRnd']) ?>;
77
- document.getElementById("MiddAds").checked = <?php echo(truefalse($QData['Default']['MiddAds'])) ?>;
78
- document.getElementById("MiddRnd").selectedIndex = <?php echo($QData['Default']['MiddRnd']) ?>;
79
- document.getElementById("EndiAds").checked = <?php echo(truefalse($QData['Default']['EndiAds'])) ?>;
80
- document.getElementById("EndiRnd").selectedIndex = <?php echo($QData['Default']['EndiRnd']) ?>;
81
- document.getElementById("MoreAds").checked = <?php echo(truefalse($QData['Default']['MoreAds'])) ?>;
82
- document.getElementById("MoreRnd").selectedIndex = <?php echo($QData['Default']['MoreRnd']) ?>;
83
- document.getElementById("LapaAds").checked = <?php echo(truefalse($QData['Default']['LapaAds'])) ?>;
84
- document.getElementById("LapaRnd").selectedIndex = <?php echo($QData['Default']['LapaRnd']) ?>;
85
- <?php for ($j=1;$j<=$rc;$j++) { ?>
86
- document.getElementById("Par<?php echo $j; ?>Ads").checked = <?php echo(truefalse($QData['Default']['Par'.$j.'Ads'])) ?>;
87
- document.getElementById("Par<?php echo $j; ?>Rnd").selectedIndex = <?php echo($QData['Default']['Par'.$j.'Rnd']) ?>;
88
- document.getElementById("Par<?php echo $j; ?>Nup").selectedIndex = <?php echo($QData['Default']['Par'.$j.'Nup']) ?>;
89
- document.getElementById("Par<?php echo $j; ?>Con").checked = <?php echo(truefalse($QData['Default']['Par'.$j.'Con'])) ?>;
90
- <?php } ?>
91
- document.getElementById("Img1Ads").checked = <?php echo(truefalse($QData['Default']['Img1Ads'])) ?>;
92
- document.getElementById("Img1Rnd").selectedIndex = <?php echo($QData['Default']['Img1Rnd']) ?>;
93
- document.getElementById("Img1Nup").selectedIndex = <?php echo($QData['Default']['Img1Nup']) ?>;
94
- document.getElementById("Img1Con").checked = <?php echo(truefalse($QData['Default']['Img1Con'])) ?>;
95
- document.getElementById("AppHome").checked = <?php echo(truefalse($QData['Default']['AppHome'])) ?>;
96
- document.getElementById("AppPost").checked = <?php echo(truefalse($QData['Default']['AppPost'])) ?>;
97
- document.getElementById("AppPage").checked = <?php echo(truefalse($QData['Default']['AppPage'])) ?>;
98
- document.getElementById("AppCate").checked = <?php echo(truefalse($QData['Default']['AppCate'])) ?>;
99
- document.getElementById("AppArch").checked = <?php echo(truefalse($QData['Default']['AppArch'])) ?>;
100
- document.getElementById("AppTags").checked = <?php echo(truefalse($QData['Default']['AppTags'])) ?>;
101
- document.getElementById("AppMaxA").checked = <?php echo(truefalse($QData['Default']['AppMaxA'])) ?>;
102
- document.getElementById("AppSide").checked = <?php echo(truefalse($QData['Default']['AppSide'])) ?>;
103
- document.getElementById("AppLogg").checked = <?php echo(truefalse($QData['Default']['AppLogg'])) ?>;
104
- document.getElementById("QckTags").checked = <?php echo(truefalse($QData['Default']['QckTags'])) ?>;
105
- document.getElementById("QckRnds").checked = <?php echo(truefalse($QData['Default']['QckRnds'])) ?>;
106
- document.getElementById("QckOffs").checked = <?php echo(truefalse($QData['Default']['QckOffs'])) ?>;
107
- document.getElementById("QckOfPs").checked = <?php echo(truefalse($QData['Default']['QckOfPs'])) ?>;
108
- for(i=1;i<=<?php echo($QData['Ads']) ?>;i++){
109
- tp=document.getElementById("AdsCode"+i.toString()).innerHTML;
110
- if(tp==''){
111
- document.getElementById("AdsMargin"+i.toString()).value = "<?php echo($QData['DefaultAdsOpt']['AdsMargin']) ?>";
112
- document.getElementById("OptAgn"+i.toString()+"<?php echo($QData['DefaultAdsOpt']['AdsAlign']) ?>").selected = true;
113
- }
114
- }
115
- deftcheckinfo();
116
- }
117
- function selectinfo(ts) {
118
- if (ts.selectedIndex == 0) { return; }
119
- cek = new Array(
120
- document.getElementById('BegnRnd'),
121
- document.getElementById('MiddRnd'),
122
- document.getElementById('EndiRnd'),
123
- document.getElementById('MoreRnd'),
124
- document.getElementById('LapaRnd'),
125
- document.getElementById('Par1Rnd'),
126
- document.getElementById('Par2Rnd'),
127
- document.getElementById('Par3Rnd'),
128
- document.getElementById('Img1Rnd') );
129
- for (i=0;i<cek.length;i++) {
130
- if (ts != cek[i] && ts.selectedIndex == cek[i].selectedIndex) {
131
- cek[i].selectedIndex = 0;
132
- }
133
- }
134
- }
135
- function checkinfo1(selnme,ts) {
136
- document.getElementById(selnme).disabled=!ts.checked;
137
- }
138
- function checkinfo2(ts,selnm1,selnm2,selnm3,selnm4) {
139
- if(selnm1){document.getElementById(selnm1).disabled=!ts.checked};
140
- if(selnm2){document.getElementById(selnm2).disabled=!ts.checked};
141
- if(selnm3){document.getElementById(selnm3).disabled=!ts.checked};
142
- }
143
- function deftcheckinfo() {
144
- checkinfo1('BegnRnd',document.getElementById('BegnAds'));
145
- checkinfo1('MiddRnd',document.getElementById('MiddAds'));
146
- checkinfo1('EndiRnd',document.getElementById('EndiAds'));
147
- checkinfo1('MoreRnd',document.getElementById('MoreAds'));
148
- checkinfo1('LapaRnd',document.getElementById('LapaAds'));
149
- for (i=1;i<=3;i++) {
150
- checkinfo2(document.getElementById('Par'+i+'Ads'),'Par'+i+'Rnd','Par'+i+'Nup','Par'+i+'Con');
151
- }
152
- checkinfo2(document.getElementById('Img1Ads'),'Img1Rnd','Img1Nup','Img1Con');
153
- }
154
- </script>
155
-
156
- <div class="wrap">
157
- <h2>Quick Adsense <?php _e('Setting'); ?> <span style="font-size:9pt;font-style:italic">( Version <?php echo($QData['Version']) ?> )</span></h2>
158
-
159
- <form method="post" action="options.php">
160
- <?php /* wp_nonce_field('update-options'); */?>
161
-
162
- <h3 style="font-size:120%"><?php _e('Options'); ?></h3>
163
-
164
- <table border="0" cellspacing="0" cellpadding="0">
165
- <tr valign="top">
166
- <td style="width:110px"><?php _e('Adsense :'); ?></td>
167
- <td><?php _e('Place up to '); ?><select name="AdsDisp" style="width:50px;font-weight:bold">
168
- <?php for ($i=0;$i<=(int)$QData['Ads'];$i++) { ?>
169
- <option id="DisTot<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($dis==(string)$i){echo('selected');} ?>><?php echo $i; ?></option>
170
- <?php } ?></select><?php _e(' Ads on a page. Select up to <b>3 Ads</b> only if you are solely using Google Ads.'); ?><br/>
171
- <span class="description" style="font-style:italic"><?php _e('(Google allows publishers to place up to <b>3 Adsense</b> for Content on a page. If you have placed these ads manually in the page, you will need to take those into account. If you are using other Ads, you may select up to <b>10 Ads</b>.)'); ?></span><br/>
172
- <br/>
173
- </td>
174
- </tr>
175
- <tr valign="top">
176
- <td style="width:110px"><?php _e('Position :<br/>(Default)'); ?></td>
177
- <td>
178
- <input type="checkbox" id="BegnAds" name="BegnAds" value="true" <?php if($ra1){echo('checked');} ?> onchange="checkinfo1('BegnRnd',this)" /> <?php _e('Assign') ; ?> <select id="BegnRnd" name="BegnRnd" onchange="selectinfo(this)">
179
- <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
180
- <option id="OptBegn<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($ra2==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
181
- <?php } ?></select> <?php _e('to <b>Beginning of Post</b>') ?><br/>
182
- <input type="checkbox" id="MiddAds" name="MiddAds" value="false" <?php if($rm1){echo('checked');} ?> onchange="checkinfo1('MiddRnd',this)" /> <?php _e('Assign') ; ?> <select id="MiddRnd" name="MiddRnd" onchange="selectinfo(this)">
183
- <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
184
- <option id="OptMidd<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rm2==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
185
- <?php } ?></select> <?php _e('to <b>Middle of Post</b>') ?><br/>
186
- <input type="checkbox" id="EndiAds" name="EndiAds" value="false" <?php if($rb1){echo('checked');} ?> onchange="checkinfo1('EndiRnd',this)" /> <?php _e('Assign') ; ?> <select id="EndiRnd" name="EndiRnd" onchange="selectinfo(this)">
187
- <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
188
- <option id="OptEndi<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rb2==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
189
- <?php } ?></select> <?php _e('to <b>End of Post</b>') ?><br/>
190
- <input type="checkbox" id="MoreAds" name="MoreAds" value="false" <?php if($rr1){echo('checked');} ?> onchange="checkinfo1('MoreRnd',this)" /> <?php _e('Assign') ; ?> <select id="MoreRnd" name="MoreRnd" onchange="selectinfo(this)">
191
- <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
192
- <option id="OptMore<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rr2==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
193
- <?php } ?></select> <?php _e('right after <b>the') ?> <span style="font-family:Courier New,Courier,Fixed;">&lt;!--more--&gt;</span> <?php _e('tag') ?></b><br/>
194
- <input type="checkbox" id="LapaAds" name="LapaAds" value="false" <?php if($rp1){echo('checked');} ?> onchange="checkinfo1('LapaRnd',this)" /> <?php _e('Assign') ; ?> <select id="LapaRnd" name="LapaRnd" onchange="selectinfo(this)">
195
- <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
196
- <option id="OptLapa<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rp2==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
197
- <?php } ?></select> <?php _e('right before <b>the last Paragraph</b>') ?><span style="color:#a00;"> <b>(New)</b></span><br/>
198
- <?php for ($j=1;$j<=$rc;$j++) { ?>
199
- <input type="checkbox" id="Par<?php echo $j; ?>Ads" name="Par<?php echo $j; ?>Ads" value="false" <?php if($rc1[$j]){echo('checked');} ?> onchange="checkinfo2(this,'Par<?php echo $j; ?>Rnd','Par<?php echo $j; ?>Nup','Par<?php echo $j; ?>Con')" /> <?php _e('Assign') ; ?> <select id="Par<?php echo $j; ?>Rnd" name="Par<?php echo $j; ?>Rnd" onchange="selectinfo(this)">
200
- <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
201
- <option id="OptPar<?php echo $j; ?><?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rc2[$j]==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
202
- <?php } ?></select> <?php _e('<b>After Paragraph</b> ') ?> <select id="Par<?php echo $j; ?>Nup" name="Par<?php echo $j; ?>Nup">
203
- <?php for ($i=1;$i<=50;$i++) { ?>
204
- <option id="Opt<?php echo $j; ?>Nu<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rc3[$j]==(string)$i){echo('selected');} ?>><?php echo $i; ?></option>
205
- <?php } ?></select> &rarr;
206
- <input type="checkbox" id="Par<?php echo $j; ?>Con" name="Par<?php echo $j; ?>Con" value="false" <?php if($rc4[$j]){echo('checked');} ?> /> <?php _e('to <b>End of Post</b> if fewer paragraphs are found.') ; ?><br/>
207
- <?php } ?>
208
- <input type="checkbox" id="Img1Ads" name="Img1Ads" value="false" <?php if($rd1){echo('checked');} ?> onchange="checkinfo2(this,'Img1Rnd','Img1Nup','Img1Con')" /> <?php _e('Assign') ; ?> <select id="Img1Rnd" name="Img1Rnd" onchange="selectinfo(this)">
209
- <?php for ($i=0;$i<=$QData['Ads'];$i++) { ?>
210
- <option id="OptImg1<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rd2==(string)$i){echo('selected');} ?>><?php _e(($i==0)?'Random Ads':'Ads'.$i) ; ?></option>
211
- <?php } ?></select> <?php _e('<b>After Image</b> ') ?> <select id="Img1Nup" name="Img1Nup">
212
- <?php for ($i=1;$i<=50;$i++) { ?>
213
- <option id="Opt1Im<?php echo $i; ?>" value="<?php echo $i; ?>" <?php if($rd3==(string)$i){echo('selected');} ?>><?php echo $i; ?></option>
214
- <?php } ?></select> &rarr;
215
- <input type="checkbox" id="Img1Con" name="Img1Con" value="false" <?php if($rd4){echo('checked');} ?> /> <?php _e('after <b>Image&#39;s outer</b>'); ?><b><span style="font-family:Courier New,Courier,Fixed;"> &lt;div&gt; wp-caption</span></b> if any.<span style="color:#a00;"> <b>(New)</b></span><br/>
216
- <br/>
217
- <script type="text/javascript">deftcheckinfo();</script>
218
- </td>
219
- </tr>
220
- <tr valign="top">
221
- <td style="width:110px"><?php _e('Appearance :'); ?></td>
222
- <td>
223
- <span>[ </span>
224
- <input type="checkbox" id="AppPost" name="AppPost" value="true" <?php if($aps){echo('checked');} ?> /> <?php _e('Posts'); ?>
225
- <input type="checkbox" id="AppPage" name="AppPage" value="true" <?php if($apg){echo('checked');} ?> /> <?php _e('Pages'); ?><span> ]</span><br/>
226
- <span>[ </span>
227
- <input type="checkbox" id="AppHome" name="AppHome" value="true" <?php if($ahm){echo('checked');} ?> /> <?php _e('Homepage'); ?>
228
- <input type="checkbox" id="AppCate" name="AppCate" value="true" <?php if($act){echo('checked');} ?> /> <?php _e('Categories'); ?>
229
- <input type="checkbox" id="AppArch" name="AppArch" value="true" <?php if($aar){echo('checked');} ?> /> <?php _e('Archives'); ?>
230
- <input type="checkbox" id="AppTags" name="AppTags" value="true" <?php if($atg){echo('checked');} ?> /> <?php _e('Tags'); ?><span> ] &rarr; </span>
231
- <input type="checkbox" id="AppMaxA" name="AppMaxA" value="true" <?php if($amx){echo('checked');} ?> /> <?php _e('Place all possible Ads on these pages.'); ?><br/>
232
- <span>[ </span>
233
- <input type="checkbox" id="AppSide" name="AppSide" value="true" <?php if($asd){echo('checked');} ?> /> <?php _e('Disable AdsWidget on Homepage'); ?><span> ]</span><br/>
234
- <span>[ </span>
235
- <input type="checkbox" id="AppLogg" name="AppLogg" value="true" <?php if($lgg){echo('checked');} ?> /> <?php _e('Hide Ads when user is logged in to Wordpress'); ?><span> ]</span><br/>
236
- <br/>
237
- </td>
238
- </tr>
239
- <tr valign="top">
240
- <td style="width:110px"><?php _e('Quicktag :'); ?></td>
241
- <td><span style="display:block;font-style:normal;padding-bottom:0px"><?php _e('Insert Ads into a post, on-the-fly :'); ?></span>
242
- <ol style="margin-top:5px;">
243
- <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--Ads1--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--Ads2--&gt;</span>, etc. into a post to show the <b>Particular Ads</b> at specific location.'); ?></li>
244
- <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--RndAds--&gt;</span> (or more) into a post to show the <b>Random Ads</b> at specific location.'); ?></li>
245
- </ol>
246
- <span style="display:block;font-style:normal;padding-bottom:0px"><?php _e('Disable Ads in a post, on-the-fly :'); ?></span>
247
- <ol style="margin-top:5px;">
248
- <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--NoAds--&gt;</span> to <b>disable all Ads</b> in a post.'); ?><span class="description" style="font-style:italic"><?php _e(' (does not affect Ads on Sidebar)'); ?></span></li>
249
- <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffDef--&gt;</span> to <b>disable the default positioned Ads</b>, and use <span style="font-family:Courier New,Courier,Fixed;">&lt;!--Ads1--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;">&lt;!--Ads2--&gt;</span>, etc. to insert Ads.'); ?><span class="description" style="font-style:italic"><?php _e(' (does not affect Ads on Sidebar)'); ?></span></li>
250
- <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffWidget--&gt;</span> to <b>disable all Ads on Sidebar</b>.'); ?><span style="color:#a00;"> <b>(New)</b></span></li>
251
- <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBegin--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffMiddle--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffEnd--&gt;</span> to <b>disable Ads at Beginning, Middle</b> or <b>End of Post</b>.'); ?><span style="color:#a00;"> <b>(New)</b></span></li>
252
- <li><?php _e('Insert <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffAfMore--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBfLastPara--&gt;</span> to <b>disable Ads right after the <span style="font-family:Courier New,Courier,Fixed;">&lt;!--more--&gt;</span> tag</b>, or <b>right before the last Paragraph</b>.'); ?><span style="color:#a00;"> <b>(New)</b></span></li>
253
- </ol>
254
- [ <input type="checkbox" id="QckTags" name="QckTags" value="true" <?php if($aqt){echo('checked');} ?> /> <?php _e('Show Quicktag Buttons on the HTML Edit Post SubPanel'); ?> ]<br/>
255
- [ <input type="checkbox" id="QckRnds" name="QckRnds" value="true" <?php if($aqr){echo('checked');} ?> /> <?php _e('Hide <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--RndAds--&gt;</span> from Quicktag Buttons'); ?> ]<br/>
256
- [ <input type="checkbox" id="QckOffs" name="QckOffs" value="true" <?php if($aqf){echo('checked');} ?> /> <?php _e('Hide <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--NoAds--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffDef--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffWidget--&gt;</span> from Quicktag Buttons'); ?> ]<br/>
257
- [ <input type="checkbox" id="QckOfPs" name="QckOfPs" value="true" <?php if($aqp){echo('checked');} ?> /> <?php _e('Hide <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBegin--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffMiddle--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffEnd--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffAfMore--&gt;</span>, <span style="font-family:Courier New,Courier,Fixed;color:#050">&lt;!--OffBfLastPara--&gt;</span> from Quicktag Buttons'); ?> ]<br/>
258
- <span class="description" style="display:block;font-style:italic;padding-top:10px"><?php _e('Tags can be inserted into a post via the additional Quicktag Buttons at the HTML Edit Post SubPanel.'); ?></span><br/>
259
- </td>
260
- </tr>
261
- <tr valign="top">
262
- <td style="width:110px"><?php _e('Infomation :'); ?></td>
263
- <td>
264
- <span><?php echo(__(
265
- 'A link from your blog to <a href="http://quicksense.net" target="_blank">http://quicksense.net</a> would be appreciated.'
266
- )); ?></span>
267
- </td>
268
- </tr>
269
-
270
- </table>
271
-
272
- <p style="margin-top:20px">( <a href="javascript:defaultoptions()"><?php _e('Load Default Setting') ?></a> )<br/><br/></p>
273
-
274
- <h3 style="font-size:120%;margin-bottom:5px"><?php _e('Adsense Codes'); ?></h3>
275
- <p style="margin-top:0px"><span class="description"><?php _e('Paste up to <b>'.$QData['Ads'].' Ads codes</b> on Post Body as assigned above, and up to <b>'.$QData['AdsWid'].' Ads codes</b> on Sidebar Widget. Ads codes provided must <b>not</b> be identical, repeated codes may result the Ads not being display correctly. Ads will never displays more than once in a page.') ?></span></p>
276
-
277
- <h4><?php _e('Ads on Post Body :'); ?></h4>
278
- <table border="0" cellspacing="0" cellpadding="0">
279
- <?php for ($i=1;$i<=$QData['Ads'];$i++) {
280
- $cod = htmlentities(get_option('AdsCode'.$i));
281
- $agn = get_option('AdsAlign'.$i);
282
- $mar = get_option('AdsMargin'.$i);
283
- $optionsupdate .= ',AdsCode'.$i.',AdsAlign'.$i.',AdsMargin'.$i;
284
- ?>
285
- <tr valign="top">
286
- <td align="left" style="width:110px">Ads<?php echo $i; ?> :</td>
287
- <td align="left"><textarea style="margin:0 5px 3px 0" id="AdsCode<?php echo $i; ?>" name="AdsCode<?php echo $i; ?>" rows="3" cols="50"><?php echo $cod; ?></textarea></td>
288
- <td align="left">
289
- <select name="AdsAlign<?php echo $i; ?>">
290
- <option id="OptAgn<?php echo $i; ?>1" value="1" <?php if($agn=="1"){echo('selected');} ?>><?php _e('Left') ; ?></option>
291
- <option id="OptAgn<?php echo $i; ?>2" value="2" <?php if($agn=="2"){echo('selected');} ?>><?php _e('Center') ; ?></option>
292
- <option id="OptAgn<?php echo $i; ?>3" value="3" <?php if($agn=="3"){echo('selected');} ?>><?php _e('Right') ; ?></option>
293
- <option id="OptAgn<?php echo $i; ?>4" value="4" <?php if($agn=="4"){echo('selected');} ?>><?php _e('None') ; ?></option></select> <?php _e('alignment'); ?><br/>
294
- <input style="width:35px;text-align:right;" id="AdsMargin<?php echo $i; ?>" name="AdsMargin<?php echo $i; ?>" value="<?php echo stripslashes(htmlspecialchars($mar)); ?>" />px <?php _e('margin'); ?><br/>
295
- </td>
296
- </tr>
297
- <?php } ?>
298
- </table>
299
-
300
- <h4><?php _e('Ads on Sidebar Widget '); ?><span style="font-weight:normal">(<a href="widgets.php"><?php _e('Drag to Sidebar'); ?></a>)</span> :</h4>
301
- <table border="0" cellspacing="0" cellpadding="0">
302
- <?php for ($i=1;$i<=$QData['AdsWid'];$i++) {
303
- $cod = htmlentities(get_option('WidCode'.$i));
304
- $optionsupdate .= ',WidCode'.$i;
305
- ?>
306
- <tr valign="top">
307
- <td align="left" style="width:110px">AdsWidget<?php echo $i; ?> :</td>
308
- <td align="left"><textarea style="margin:0 5px 3px 0" id="WidCode<?php echo $i; ?>" name="WidCode<?php echo $i; ?>" rows="3" cols="50"><?php echo $cod; ?></textarea></td>
309
- </tr>
310
- <?php } ?>
311
- </table>
312
-
313
- <input type="hidden" name="action" value="update" />
314
- <?php /* <input type="hidden" name="page_options" value="<?php echo $optionsupdate; ?>" /> */ ?>
315
- <?php settings_fields('qa-options'); ?>
316
- <div style="width:580px">
317
-
318
- <p class="submit">
319
- <input type="submit" value="<?php _e('Save Changes') ?>" />
320
- </p>
321
- </div>
322
-
323
- </form>
324
-
325
- </div>
326
-
327
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
quick-adsense.php CHANGED
@@ -1,16 +1,13 @@
1
  <?php
2
-
3
  /*
4
  Plugin Name: Quick Adsense
5
- Plugin URI: http://quicksense.net/
6
  Description: Quick Adsense offers a quicker & flexible way to insert Google Adsense or any Ads code into a blog post.
7
- Author: Quicksense
8
- Version: 1.9.2
9
- Author URI: http://quicksense.net/
10
  */
11
-
12
- /* Copyright 2009-2013 BuySellAds [ http://quicksense.net/ ]
13
-
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
16
  the Free Software Foundation; either version 2 of the License, or
@@ -25,480 +22,7 @@
25
  along with this program; if not, write to the Free Software
26
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
-
29
-
30
-
31
-
32
-
33
- global $QData;
34
- $QData['AdsWid'] = 10; /* Ads on Widget */
35
- $QData['Ads'] = 10; /* Ads on Post body */
36
- $QData['Name'] = 'Quick Adsense';
37
- $QData['Version'] = '1.9.2';
38
- $QData['URI'] = 'http://quicksense.net/';
39
- $QData['AdsWidName'] = 'AdsWidget%d (Quick Adsense)';
40
- $QData['Default'] = array(
41
- 'AdsDisp'=>'3',
42
- 'BegnAds'=>true,'BegnRnd'=>'1','EndiAds'=>true,'EndiRnd'=>'0','MiddAds'=>false,'MiddRnd'=>'0','MoreAds'=>false,'MoreRnd'=>'0','LapaAds'=>false,'LapaRnd'=>'0',
43
- 'Par1Ads'=>false,'Par1Rnd'=>'0','Par1Nup'=>'0','Par1Con'=>false,
44
- 'Par2Ads'=>false,'Par2Rnd'=>'0','Par2Nup'=>'0','Par2Con'=>false,
45
- 'Par3Ads'=>false,'Par3Rnd'=>'0','Par3Nup'=>'0','Par3Con'=>false,
46
- 'Img1Ads'=>false,'Img1Rnd'=>'0','Img1Nup'=>'0','Img1Con'=>true,
47
- 'AppPost'=>true,'AppPage'=>true,'AppHome'=>false,'AppCate'=>false,'AppArch'=>false,'AppTags'=>false,'AppMaxA'=>false,'AppSide'=>false,'AppLogg'=>false,
48
- 'QckTags'=>true,'QckRnds'=>false,'QckOffs'=>false,'QckOfPs'=>false
49
- );
50
- $QData['DefaultAdsOpt'] = array(
51
- 'AdsMargin'=>'10','AdsAlign'=>'2'
52
- );
53
- $QData['DefaultAdsName'] = array();
54
- for ($i=1;$i<=$QData['Ads'];$i++) {
55
- array_push($QData['DefaultAdsName'], 'AdsCode'.$i );
56
- array_push($QData['DefaultAdsName'], 'AdsAlign'.$i );
57
- array_push($QData['DefaultAdsName'], 'AdsMargin'.$i );
58
- };
59
- for ($i=1;$i<=$QData['AdsWid'];$i++) {
60
- array_push($QData['DefaultAdsName'], 'WidCode'.$i );
61
- };
62
-
63
- function ads_admin_page_inc() {
64
- include('quick-adsense-admin.php');
65
- }
66
- function ads_admin_page() {
67
- add_options_page("Quick Adsense Options", "Quick Adsense", 8, basename(__FILE__), "ads_admin_page_inc");
68
- }
69
- function register_ads_settings() {
70
- global $QData;
71
- foreach ($QData['Default'] as $key => $value) {
72
- register_setting( 'qa-options', $key);
73
- }
74
- foreach ($QData['DefaultAdsName'] as $key => $value) {
75
- register_setting( 'qa-options', $value);
76
- }
77
- }
78
- if(is_admin()) {
79
- add_action('admin_menu', 'ads_admin_page');
80
- add_action('admin_init', 'register_ads_settings');
81
- }
82
-
83
-
84
- function ads_plugin_links($links,$file) {
85
- if($file==plugin_basename(__FILE__)) {
86
- array_unshift($links,'<a href="options-general.php?page='.basename(__FILE__).'">'.__('Setting').'</a>');
87
- }
88
- return $links;
89
- }
90
- add_filter('plugin_action_links','ads_plugin_links',10,2);
91
-
92
-
93
- function plugin_activated() {
94
- global $QData;
95
- $isold = get_option('AdsDisp');
96
- if ( !$isold && is_bool($isold) ) {
97
- foreach ($QData['Default'] as $key => $value) {
98
- update_option($key , $value);
99
- }
100
- for ($i=1;$i<=$QData['Ads'];$i++) {
101
- update_option('AdsMargin'.$i, $QData['DefaultAdsOpt']['AdsMargin']);
102
- update_option('AdsAlign'.$i, $QData['DefaultAdsOpt']['AdsAlign']);
103
- }
104
- }
105
- }
106
- register_activation_hook( __FILE__, 'plugin_activated' );
107
-
108
-
109
- $wpvcomp = (bool)(version_compare($wp_version, '3.1', '>='));
110
- function ads_head_java() {
111
- global $QData;
112
- global $wpvcomp;
113
- if (get_option('QckTags')) { ?>
114
- <script type="text/javascript">
115
- wpvcomp = <?php echo(($wpvcomp==1)?"true":"false"); ?>;
116
- edaddID = new Array();
117
- edaddNm = new Array();
118
- if(typeof(edButtons)!='undefined') {
119
- edadd = edButtons.length;
120
- var dynads={"all":[
121
- <?php for ($i=1;$i<=$QData['Ads'];$i++) { if(get_option('AdsCode'.$i)!=''){echo('"1",');}else{echo('"0",');}; } ?>
122
- "0"]};
123
- for(i=1;i<=<?php echo($QData['Ads']) ?>;i++) {
124
- if(dynads.all[i-1]=="1") {
125
- edButtons[edButtons.length]=new edButton("ads"+i.toString(),"Ads"+i.toString(),"\n<!--Ads"+i.toString()+"-->\n","","",-1);
126
- edaddID[edaddID.length] = "ads"+i.toString();
127
- edaddNm[edaddNm.length] = "Ads"+i.toString();
128
- }
129
- }
130
- <?php if(!get_option('QckRnds')){ ?>
131
- edButtons[edButtons.length]=new edButton("random_ads","RndAds","\n<!--RndAds-->\n","","",-1);
132
- edaddID[edaddID.length] = "random_ads";
133
- edaddNm[edaddNm.length] = "RndAds";
134
- <?php } ?>
135
- <?php if(!get_option('QckOffs')){ ?>
136
- edButtons[edButtons.length]=new edButton("no_ads","NoAds","\n<!--NoAds-->\n","","",-1);
137
- edaddID[edaddID.length] = "no_ads";
138
- edaddNm[edaddNm.length] = "NoAds";
139
- edButtons[edButtons.length]=new edButton("off_def","OffDef","\n<!--OffDef-->\n","","",-1);
140
- edaddID[edaddID.length] = "off_def";
141
- edaddNm[edaddNm.length] = "OffDef";
142
- edButtons[edButtons.length]=new edButton("off_wid","OffWidget","\n<!--OffWidget-->\n","","",-1);
143
- edaddID[edaddID.length] = "off_wid";
144
- edaddNm[edaddNm.length] = "OffWidget";
145
- <?php } ?>
146
- <?php if(!get_option('QckOfPs')){ ?>
147
- edButtons[edButtons.length]=new edButton("off_bgn","OffBegin","\n<!--OffBegin-->\n","","",-1);
148
- edaddID[edaddID.length] = "off_bgn";
149
- edaddNm[edaddNm.length] = "OffBegin";
150
- edButtons[edButtons.length]=new edButton("off_mid","OffMiddle","\n<!--OffMiddle-->\n","","",-1);
151
- edaddID[edaddID.length] = "off_mid";
152
- edaddNm[edaddNm.length] = "OffMiddle";
153
- edButtons[edButtons.length]=new edButton("off_end","OffEnd","\n<!--OffEnd-->\n","","",-1);
154
- edaddID[edaddID.length] = "off_end";
155
- edaddNm[edaddNm.length] = "OffEnd";
156
- edButtons[edButtons.length]=new edButton("off_more","OffAfMore","\n<!--OffAfMore-->\n","","",-1);
157
- edaddID[edaddID.length] = "off_more";
158
- edaddNm[edaddNm.length] = "OffAfMore";
159
- edButtons[edButtons.length]=new edButton("off_last","OffBfLastPara","\n<!--OffBfLastPara-->\n","","",-1);
160
- edaddID[edaddID.length] = "off_last";
161
- edaddNm[edaddNm.length] = "OffBfLastPara";
162
- <?php } ?>
163
- };
164
- (function(){
165
- if(typeof(edButtons)!='undefined' && typeof(jQuery)!='undefined' && wpvcomp){
166
- jQuery(document).ready(function(){
167
- for(i=0;i<edaddID.length;i++) {
168
- jQuery("#ed_toolbar").append('<input type="button" value="' + edaddNm[i] +'" id="' + edaddID[i] +'" class="ed_button" onclick="edInsertTag(edCanvas, ' + (edadd+i) + ');" title="' + edaddNm[i] +'" />');
169
- }
170
- });
171
- }
172
- }());
173
- </script>
174
- <?php }
175
- }
176
- if ($wpvcomp) {
177
- add_action('admin_print_footer_scripts', 'ads_head_java');
178
- }else{
179
- add_action('admin_head', 'ads_head_java');
180
- }
181
-
182
-
183
- $ShownAds = 0;
184
- $AdsId = array();
185
- $beginend = 0;
186
-
187
- function process_content($content)
188
- {
189
- global $QData;
190
- global $ShownAds;
191
- global $AdsId;
192
- global $beginend;
193
-
194
- /* verifying */
195
- if( (is_feed()) ||
196
- (strpos($content,'<!--NoAds-->')!==false) ||
197
- (strpos($content,'<!--OffAds-->')!==false) ||
198
- (is_single() && !(get_option('AppPost'))) ||
199
- (is_page() && !(get_option('AppPage'))) ||
200
- (is_home() && !(get_option('AppHome'))) ||
201
- (is_category() && !(get_option('AppCate'))) ||
202
- (is_archive() && !(get_option('AppArch'))) ||
203
- (is_tag() && !(get_option('AppTags'))) ||
204
- (is_user_logged_in() && (get_option('AppLogg'))) ) {
205
- $content = clean_tags($content); return $content;
206
- }
207
-
208
- $AdsToShow = get_option('AdsDisp');
209
- if (strpos($content,'<!--OffWidget-->')===false) {
210
- for($i=1;$i<=$QData['AdsWid'];$i++) {
211
- $wadsid = sanitize_title(str_replace(array('(',')'),'',sprintf($QData['AdsWidName'],$i)));
212
- $AdsToShow -= (is_active_widget(true, $wadsid)) ? 1 : 0 ;
213
- }
214
- }
215
- if( $ShownAds >= $AdsToShow ) { $content = clean_tags($content); return $content; };
216
-
217
- if( !count($AdsId) ) {
218
- for($i=1;$i<=$QData['Ads'];$i++) {
219
- $tmp = trim(get_option('AdsCode'.$i));
220
- if( !empty($tmp) ) {
221
- array_push($AdsId, $i);
222
- }
223
- }
224
- }
225
- if( !count($AdsId) ) { $content = clean_tags($content); return $content; };
226
-
227
- /* ... Tidy up content ... */
228
- $content = str_replace("<p></p>", "##QA-TP1##", $content);
229
- $content = str_replace("<p>&nbsp;</p>", "##QA-TP2##", $content);
230
- $offdef = (strpos($content,'<!--OffDef-->')!==false);
231
- if( !$offdef ) {
232
- $AdsIdCus = array();
233
- $cusads = 'CusAds'; $cusrnd = 'CusRnd';
234
- $more1 = get_option('MoreAds'); $more2 = get_option('MoreRnd');
235
- $lapa1 = get_option('LapaAds'); $lapa2 = get_option('LapaRnd');
236
- $begn1 = get_option('BegnAds'); $begn2 = get_option('BegnRnd');
237
- $midd1 = get_option('MiddAds'); $midd2 = get_option('MiddRnd');
238
- $endi1 = get_option('EndiAds'); $endi2 = get_option('EndiRnd');
239
- $rc=3;
240
- for($i=1;$i<=$rc;$i++) {
241
- $para1[$i] = get_option('Par'.$i.'Ads'); $para2[$i] = get_option('Par'.$i.'Rnd'); $para3[$i] = get_option('Par'.$i.'Nup'); $para4[$i] = get_option('Par'.$i.'Con');
242
- }
243
- $imge1 = get_option('Img1Ads'); $imge2 = get_option('Img1Rnd'); $imge3 = get_option('Img1Nup'); $imge4 = get_option('Img1Con');
244
- if ( $begn2 == 0 ) { $b1 = $cusrnd; } else { $b1 = $cusads.$begn2; array_push($AdsIdCus, $begn2); };
245
- if ( $more2 == 0 ) { $r1 = $cusrnd; } else { $r1 = $cusads.$more2; array_push($AdsIdCus, $more2); };
246
- if ( $midd2 == 0 ) { $m1 = $cusrnd; } else { $m1 = $cusads.$midd2; array_push($AdsIdCus, $midd2); };
247
- if ( $lapa2 == 0 ) { $g1 = $cusrnd; } else { $g1 = $cusads.$lapa2; array_push($AdsIdCus, $lapa2); };
248
- if ( $endi2 == 0 ) { $b2 = $cusrnd; } else { $b2 = $cusads.$endi2; array_push($AdsIdCus, $endi2); };
249
- for($i=1;$i<=$rc;$i++) {
250
- if ( $para2[$i] == 0 ) { $b3[$i] = $cusrnd; } else { $b3[$i] = $cusads.$para2[$i]; array_push($AdsIdCus, $para2[$i]); };
251
- }
252
- if ( $imge2 == 0 ) { $b4 = $cusrnd; } else { $b4 = $cusads.$imge2; array_push($AdsIdCus, $imge2); };
253
- if( $midd1 && strpos($content,'<!--OffMiddle-->')===false) {
254
- if( substr_count(strtolower($content), '</p>')>=2 ) {
255
- $sch = "</p>";
256
- $content = str_replace("</P>", $sch, $content);
257
- $arr = explode($sch, $content);
258
- $nn = 0; $mm = strlen($content)/2;
259
- for($i=0;$i<count($arr);$i++) {
260
- $nn += strlen($arr[$i]) + 4;
261
- if($nn>$mm) {
262
- if( ($mm - ($nn - strlen($arr[$i]))) > ($nn - $mm) && $i+1<count($arr) ) {
263
- $arr[$i+1] = '<!--'.$m1.'-->'.$arr[$i+1];
264
- } else {
265
- $arr[$i] = '<!--'.$m1.'-->'.$arr[$i];
266
- }
267
- break;
268
- }
269
- }
270
- $content = implode($sch, $arr);
271
- }
272
- }
273
- if( $more1 && strpos($content,'<!--OffAfMore-->')===false) {
274
- $mmr = '<!--'.$r1.'-->';
275
- $postid = get_the_ID();
276
- $content = str_replace('<span id="more-'.$postid.'"></span>', $mmr, $content);
277
- }
278
- if( $begn1 && strpos($content,'<!--OffBegin-->')===false) {
279
- $content = '<!--'.$b1.'-->'.$content;
280
- }
281
- if( $endi1 && strpos($content,'<!--OffEnd-->')===false) {
282
- $content = $content.'<!--'.$b2.'-->';
283
- }
284
- if( $lapa1 && strpos($content,'<!--OffBfLastPara-->')===false){
285
- $sch = "<p>";
286
- $content = str_replace("<P>", $sch, $content);
287
- $arr = explode($sch, $content);
288
- if ( count($arr) > 2 ) {
289
- $content = implode($sch, array_slice($arr, 0, count($arr)-1)) .'<!--'.$g1.'-->'. $sch. $arr[count($arr)-1];
290
- }
291
- }
292
- for($i=$rc;$i>=1;$i--) {
293
- if ( $para1[$i] ){
294
- $sch = "</p>";
295
- $content = str_replace("</P>", $sch, $content);
296
- $arr = explode($sch, $content);
297
- if ( (int)$para3[$i] < count($arr) ) {
298
- $content = implode($sch, array_slice($arr, 0, $para3[$i])).$sch .'<!--'.$b3[$i].'-->'. implode($sch, array_slice($arr, $para3[$i]));
299
- } elseif ($para4[$i]) {
300
- $content = implode($sch, $arr).'<!--'.$b3[$i].'-->';
301
- }
302
- }
303
- }
304
- if ( $imge1 ){
305
- $sch = "<img"; $bch = ">"; $cph = "[/caption]"; $csa = "</a>";
306
- $content = str_replace("<IMG", $sch, $content);
307
- $content = str_replace("</A>", $csa, $content);
308
- $arr = explode($sch, $content);
309
- if ( (int)$imge3 < count($arr) ) {
310
- $trr = explode($bch, $arr[$imge3]);
311
- if ( count($trr) > 1 ) {
312
- $tss = explode($cph, $arr[$imge3]);
313
- $ccp = ( count($tss) > 1 ) ? strpos(strtolower($tss[0]),'[caption ')===false : false ;
314
- $tuu = explode($csa, $arr[$imge3]);
315
- $cdu = ( count($tuu) > 1 ) ? strpos(strtolower($tuu[0]),'<a href')===false : false ;
316
- if ( $imge4 && $ccp ) {
317
- $arr[$imge3] = implode($cph, array_slice($tss, 0, 1)).$cph. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($cph, array_slice($tss, 1));
318
- }else if ( $cdu ) {
319
- $arr[$imge3] = implode($csa, array_slice($tuu, 0, 1)).$csa. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($csa, array_slice($tuu, 1));
320
- }else{
321
- $arr[$imge3] = implode($bch, array_slice($trr, 0, 1)).$bch. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($bch, array_slice($trr, 1));
322
- }
323
- }
324
- $content = implode($sch, $arr);
325
- }
326
- }
327
- }
328
-
329
- /* ... Tidy up content ... */
330
- $content = '<!--EmptyClear-->'.$content."\n".'<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>';
331
- $content = clean_tags($content, true);
332
- $ismany = (!is_single() && !is_page());
333
- $showall = get_option('AppMaxA');
334
-
335
- /* ... Replace Beginning/Middle/End Ads1-10 ... */
336
- if( !$offdef ) {
337
- for( $i=1; $i<=count($AdsIdCus); $i++ ) {
338
- if( $showall || !$ismany || $beginend != $i ) {
339
- if( strpos($content,'<!--'.$cusads.$AdsIdCus[$i-1].'-->')!==false && in_array($AdsIdCus[$i-1], $AdsId)) {
340
- $content = replace_ads( $content, $cusads.$AdsIdCus[$i-1], $AdsIdCus[$i-1] ); $AdsId = del_element($AdsId, array_search($AdsIdCus[$i-1], $AdsId)) ;
341
- $ShownAds += 1; if( $ShownAds >= $AdsToShow || !count($AdsId) ){ $content = clean_tags($content); return $content; };
342
- $beginend = $i; if(!$showall && $ismany){break;}
343
- }
344
- }
345
- }
346
- }
347
-
348
- /* ... Replace Ads1 to Ads10 ... */
349
- if( $showall || !$ismany ) {
350
- $tcn = count($AdsId); $tt = 0;
351
- for( $i=1; $i<=$tcn; $i++ ) {
352
- if( strpos($content, '<!--Ads'.$AdsId[$tt].'-->')!==false ) {
353
- $content = replace_ads( $content, 'Ads'.$AdsId[$tt], $AdsId[$tt] ); $AdsId = del_element($AdsId, $tt) ;
354
- $ShownAds += 1; if( $ShownAds >= $AdsToShow || !count($AdsId) ){ $content = clean_tags($content); return $content; };
355
- } else {
356
- $tt += 1;
357
- }
358
- }
359
- }
360
-
361
- /* ... Replace Beginning/Middle/End random Ads ... */
362
- if( strpos($content, '<!--'.$cusrnd.'-->')!==false && ($showall || !$ismany) ) {
363
- $tcx = count($AdsId);
364
- $tcy = substr_count($content, '<!--'.$cusrnd.'-->');
365
- for( $i=$tcx; $i<=$tcy-1; $i++ ) {
366
- array_push($AdsId, -1);
367
- }
368
- shuffle($AdsId);
369
- for( $i=1; $i<=$tcy; $i++ ) {
370
- $content = replace_ads( $content, $cusrnd, $AdsId[0] ); $AdsId = del_element($AdsId, 0) ;
371
- $ShownAds += 1; if( $ShownAds >= $AdsToShow || !count($AdsId) ){ $content = clean_tags($content); return $content; };
372
- }
373
- }
374
-
375
- /* ... Replace RndAds ... */
376
- if( strpos($content, '<!--RndAds-->')!==false && ($showall || !$ismany) ) {
377
- $AdsIdTmp = array();
378
- shuffle($AdsId);
379
- for( $i=1; $i<=$AdsToShow-$ShownAds; $i++ ) {
380
- if( $i <= count($AdsId) ) {
381
- array_push($AdsIdTmp, $AdsId[$i-1]);
382
- }
383
- }
384
- $tcx = count($AdsIdTmp);
385
- $tcy = substr_count($content, '<!--RndAds-->');
386
- for( $i=$tcx; $i<=$tcy-1; $i++ ) {
387
- array_push($AdsIdTmp, -1);
388
- }
389
- shuffle($AdsIdTmp);
390
- for( $i=1; $i<=$tcy; $i++ ) {
391
- $tmp = $AdsIdTmp[0];
392
- $content = replace_ads( $content, 'RndAds', $AdsIdTmp[0] ); $AdsIdTmp = del_element($AdsIdTmp, 0) ;
393
- if($tmp != -1){$ShownAds += 1;}; if( $ShownAds >= $AdsToShow || !count($AdsIdTmp) ){ $content = clean_tags($content); return $content; };
394
- }
395
- }
396
-
397
- /* ... That's it. DONE :) ... */
398
- $content = clean_tags($content); return $content;
399
- }
400
- function clean_tags($content, $trimonly = false) {
401
- global $QData;
402
- global $ShownAds;
403
- global $AdsId;
404
- global $beginend;
405
- $tagnames = array('EmptyClear','RndAds','NoAds','OffDef','OffAds','OffWidget','OffBegin','OffMiddle','OffEnd','OffBfMore','OffAfLastPara','CusRnd');
406
- for($i=1;$i<=$QData['Ads'];$i++) { array_push($tagnames, 'CusAds'.$i); array_push($tagnames, 'Ads'.$i); };
407
- foreach ($tagnames as $tgn) {
408
- if(strpos($content,'<!--'.$tgn.'-->')!==false || $tgn=='EmptyClear') {
409
- if($trimonly) {
410
- $content = str_replace('<p><!--'.$tgn.'--></p>', '<!--'.$tgn.'-->', $content);
411
- }else{
412
- $content = str_replace(array('<p><!--'.$tgn.'--></p>','<!--'.$tgn.'-->'), '', $content);
413
- $content = str_replace("##QA-TP1##", "<p></p>", $content);
414
- $content = str_replace("##QA-TP2##", "<p>&nbsp;</p>", $content);
415
- }
416
- }
417
- }
418
- if(!$trimonly && (is_single() || is_page()) ) {
419
- $ShownAds = 0;
420
- $AdsId = array();
421
- $beginend = 0;
422
- }
423
- return $content;
424
- }
425
- function replace_ads($content, $nme, $adn) {
426
- if( strpos($content,'<!--'.$nme.'-->')===false ) { return $content; }
427
- global $QData;
428
- if ($adn != -1) {
429
- $arr = array('',
430
- 'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
431
- 'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
432
- 'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
433
- 'float:none;margin:0px;');
434
- $adsalign = get_option('AdsAlign'.$adn);
435
- $adsmargin = get_option('AdsMargin'.$adn);
436
- $style = sprintf($arr[(int)$adsalign], $adsmargin);
437
- $adscode = get_option('AdsCode'.$adn);
438
- $adscode =
439
- "\n".'<!-- '.$QData['Name'].' Wordpress Plugin: '.$QData['URI'].' -->'."\n".
440
- '<div style="'.$style.'">'."\n".
441
- $adscode."\n".
442
- '</div>'."\n";
443
- } else {
444
- $adscode ='';
445
- }
446
- $cont = explode('<!--'.$nme.'-->', $content, 2);
447
- return $cont[0].$adscode.$cont[1];
448
- }
449
- function del_element($array, $idx) {
450
- $copy = array();
451
- for( $i=0; $i<count($array) ;$i++) {
452
- if ( $idx != $i ) {
453
- array_push($copy, $array[$i]);
454
- }
455
- }
456
- return $copy;
457
- }
458
- add_filter('the_content', 'process_content');
459
-
460
-
461
- function ads_widget_register() {
462
- global $QData;
463
- if (!function_exists('wp_register_sidebar_widget')) { return; };
464
- for($i=1;$i<=$QData['AdsWid'];$i++) {
465
- if(get_option('WidCode'.$i)!='') {
466
- $displaystr =
467
- '$cont = get_the_content();'.
468
- 'if( strpos($cont,"<!--OffAds-->")===false && strpos($cont,"<!--OffWidget-->")===false && !(is_home()&&get_option("AppSide")) ) {'.
469
- 'extract($args);'.
470
- '$title = get_option("WidCode-title-'.$i.'");'.
471
- '$codetxt = get_option("WidCode'.$i.'");'.
472
- 'echo "\n"."<!-- Quick Adsense Wordpress Plugin: http://quicksense.net/ -->"."\n";'.
473
- 'echo $before_widget."\n";'.
474
- 'if (!empty($title)) { '.
475
- 'echo $before_title.$title.$after_title."\n"; '.
476
- '};'.
477
- 'echo $codetxt;'.
478
- 'echo "\n".$after_widget;'.
479
- '}';
480
- $displaycall[$i] = create_function('$args', $displaystr);
481
- $wadnam = sprintf($QData['AdsWidName'],$i);
482
- $wadsid = sanitize_title(str_replace(array('(',')'),'',$wadnam));
483
- wp_register_sidebar_widget($wadsid, $wadnam, $displaycall[$i], array('description' => 'Quick Adsense on Sidebar Widget'));
484
- }
485
- }
486
- }
487
- function get_option_en($nameid)
488
- {
489
- $txt = get_option($nameid);
490
- $txt = htmlspecialchars($txt, ENT_QUOTES);
491
- if(!empty($txt)) { return $txt; }else{ return ""; };
492
- }
493
- function update_option_en($nameid, $text, $opt='')
494
- {
495
- $txt = stripslashes($text);
496
- if ($opt=='strip_tags') { $txt = strip_tags($txt); };
497
- update_option($nameid, $txt);
498
- if(!empty($txt)) { return $txt; }else{ return ""; };
499
- }
500
- add_action('init', 'ads_widget_register');
501
-
502
-
503
-
504
- ?>
1
  <?php
 
2
  /*
3
  Plugin Name: Quick Adsense
4
+ Plugin URI: http://quickadsense.com/
5
  Description: Quick Adsense offers a quicker & flexible way to insert Google Adsense or any Ads code into a blog post.
6
+ Author: quickadsense
7
+ Version: 1.9.4
8
+ Author URI: http://quickadsense.com/
9
  */
10
+ /*
 
 
11
  This program is free software; you can redistribute it and/or modify
12
  it under the terms of the GNU General Public License as published by
13
  the Free Software Foundation; either version 2 of the License, or
22
  along with this program; if not, write to the Free Software
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
+ require_once(dirname(__FILE__).'/includes/settings.php');
26
+ require_once(dirname(__FILE__).'/includes/ads.php');
27
+ require_once(dirname(__FILE__).'/includes/migrate.php');
28
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Quick Adsense ===
2
- Contributors: toddynho, philipze
3
  Tags: WordPress Plugin, adsense, google adsense, random adsense, random ads, advertising, adsense insertion, ad manager, ad, yahoo, google, ads, text insertion, widget, sidebar, admin, posts, plugin
4
- Requires at least: 2.5
5
- Tested up to: 3.5.1
6
- Stable tag: 1.9.2
7
 
8
  Quick Adsense offers a quicker & flexible way to insert Google Adsense or any Ads code into a blog post.
9
 
@@ -29,7 +29,7 @@ Here are some **features** that come with this plugin:
29
 
30
  Sign up for a [Google Adsense Account](http://adsense.google.com/) to generate revenue from your blog, if you don't have one.
31
 
32
- [Installation](http://wordpress.org/extend/plugins/quick-adsense/installation/) | [Screen Shots](http://wordpress.org/extend/plugins/quick-adsense/screenshots/) | [Plugin Homepage](http://quicksense.net/)
33
 
34
  == Screenshots ==
35
 
@@ -45,10 +45,20 @@ Sign up for a [Google Adsense Account](http://adsense.google.com/) to generate r
45
 
46
  == Frequently Asked Questions ==
47
 
48
- Please feedback to [http://quicksense.net/](http://quicksense.net/) for any bug you might have found, or any suggestion you like to add.
49
 
50
  == Change Log ==
51
 
 
 
 
 
 
 
 
 
 
 
52
  = 1.9.2 =
53
  * Update the depreciated wp code function for AdsWidget in the plugin.
54
  * New Feature - Enable user to insert Ads after Image's outer div wp-caption & not just right below the image.
1
  === Quick Adsense ===
2
+ Contributors: quickadsense
3
  Tags: WordPress Plugin, adsense, google adsense, random adsense, random ads, advertising, adsense insertion, ad manager, ad, yahoo, google, ads, text insertion, widget, sidebar, admin, posts, plugin
4
+ Requires at least: 4.0
5
+ Tested up to: 4.8.1
6
+ Stable tag: 1.9.4
7
 
8
  Quick Adsense offers a quicker & flexible way to insert Google Adsense or any Ads code into a blog post.
9
 
29
 
30
  Sign up for a [Google Adsense Account](http://adsense.google.com/) to generate revenue from your blog, if you don't have one.
31
 
32
+ [Installation](http://wordpress.org/extend/plugins/quick-adsense/installation/) | [Screen Shots](http://wordpress.org/extend/plugins/quick-adsense/screenshots/) | [Plugin Homepage](http://quickadsense.com/)
33
 
34
  == Screenshots ==
35
 
45
 
46
  == Frequently Asked Questions ==
47
 
48
+ Please feedback to [http://quickadsense.com/](http://quickadsense.com/) for any bug you might have found, or any suggestion you like to add.
49
 
50
  == Change Log ==
51
 
52
+ = 1.9.4 =
53
+ * The number of individual database calls has been reduced from 80 to just 1, also almost all of the legacy code has been altered and code base re-structured to be better understandable.
54
+ * Security: improved.
55
+ * Info update.
56
+ * Date: 20-September-2017
57
+
58
+ = 1.9.3 =
59
+ * Info update.
60
+ * Date: 29-August-2017
61
+
62
  = 1.9.2 =
63
  * Update the depreciated wp code function for AdsWidget in the plugin.
64
  * New Feature - Enable user to insert Ads after Image's outer div wp-caption & not just right below the image.