You are not logged in.

Announcement

Forum database was corrupt and an old backup was restored as temporary replacement. Registrations closed until the database is recovered. Please ask questions using the Contact form

#1 02-10-2013 20:03:35

steebchen
Contributors
From: Germany
Registered: 03-05-2013
Posts: 121

adblock message destroys layout

Hi, I use an anti adblock script, and when you close the message, the layout is a bit destroyed:
How can I prevent this?

cqzvhg196fro.jpg
(http://www7.pic-upload.de/02.10.13/cqzvhg196fro.jpg)

Here is the anti-adblock code

(I copied that from here)

<!-- 	ANTI ADBLOCK CODE		-->
<?php $antiblock_short_urls = array('http://bit.ly/jzgtlK','http://is.gd/ndmArO','http://is.gd/vqQzAN','http://is.gd/CTnJW3','http://ow.ly/lZZKe');?>
<?php $antiblock_message = str_replace("\r\n", "\n", 'This site is afforded by ads. Please disable your ad blocker to support it!
You can close this message in 5 seconds.

Diese Seite wird durch Werbung finanziert. Bitte deaktivieren sie deshalb ihren Werbeblocker, um diese zu unterstüzen! 
Sie können dieses Fenster in 5 Sekunden schließen.'); ?>

<?php
function imagestringbox($message) {
	$font = 5;
	$shadow = true;
	$line_spacing = mt_rand(1, 5);//random line spacing influences base64 source and image size
	$lines = explode("\n", utf8_decode($message));
	$line_count = count($lines);
	$max_len = 0;
	foreach ($lines as $line) {
		$max_len = max($max_len, strlen($line));
	}
	$line_height = imagefontheight($font);
	$image_height = ($line_height * $line_count) + ($line_spacing * ($line_count - 1));
	$image_width = imagefontwidth($font) * $max_len;
	$image = imagecreate($image_width, $image_height);
	$random_color = mt_rand(250, 255);
	imagecolorallocate($image, $random_color, $random_color, $random_color);//random color influences base64 source
	$line_spacing_i = 0;// first line does not have line spacing
	for ($i = 0; $i < $line_count; $i++) {
		if ($shadow) {
			$shadow_color = imagecolorallocate($image, 200, 200, 200);
			imagestring($image, 5, 1, $line_height * $i + $line_spacing_i + 1, $lines[$i], $shadow_color);
		}
		// text line
		imagestring($image, 5, 0, $line_height * $i + $line_spacing_i, $lines[$i], imagecolorallocate($image, 0, 0, 0));
		$line_spacing_i += $line_spacing;
	}
	ob_start();
	imagepng($image);
	$image_content = ob_get_contents();
	ob_end_clean();
	imagedestroy($image);
	return '<img src="data:image/png;base64,' . base64_encode($image_content) . '" height="' . $image_height . '" width="' . $image_width . '" alt="" />';
}
?>
<?php $antiblock_message = imagestringbox($antiblock_message); ?>
<?php $antiblock_layer_id = chr(98 + mt_rand(0,24)) . substr(md5(time()), 0, 3); ?><?php $antiblock_html_elements = array (  0 => 'div',  1 => 'span',  2 => 'b',  3 => 'i',  4 => 'font',  5 => 'strong',  6 => 'center',); $antiblock_html_element = $antiblock_html_elements[array_rand($antiblock_html_elements)]; ?>
<style>#<?php echo $antiblock_layer_id; ?>{position:fixed !important;position:absolute;top:<?php echo mt_rand(-3, 3); ?>px;top:expression((t=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)+"px");left:<?php echo mt_rand(-3, 3); ?>px;width:<?php echo mt_rand(98, 103); ?>%;height:<?php echo mt_rand(98, 103); ?>%;background-color:#fff;opacity:.95;filter:alpha(opacity=95);display:block;padding:20% 0}#<?php echo $antiblock_layer_id; ?> *{text-align:center;margin:0 auto;display:block;filter:none;font:bold 14px Verdana,Arial,sans-serif;text-decoration:none}#<?php echo $antiblock_layer_id; ?> ~ *{display:none}</style><div id="<?php echo $antiblock_layer_id; ?>"><<?php echo $antiblock_html_element; ?>>Please enable / Bitte aktiviere JavaScript!<br>Veuillez activer / Por favor activa el Javascript!<a href="<?php echo $antiblock_short_urls[ array_rand($antiblock_short_urls) ]; ?>">[ ? ]</a></<?php echo $antiblock_html_element; ?>></div><script>window.document.getElementById("<?php echo $antiblock_layer_id; ?>").parentNode.removeChild(window.document.getElementById("<?php echo $antiblock_layer_id; ?>"));(function(l,m){function n(a){a&&<?php echo $antiblock_layer_id; ?>.nextFunction()}var h=l.document,p=["i","s","u"];n.prototype={rand:function(a){return Math.floor(Math.random()*a)},getElementBy:function(a,b){return a?h.getElementById(a):h.getElementsByTagName(b)},getStyle:function(a){var b=h.defaultView;return b&&b.getComputedStyle?b.getComputedStyle(a,null):a.currentStyle},deferExecution:function(a){setTimeout(a,250)},insert:function(a,b){var c=h.createElement("<?php echo $antiblock_html_element; ?>"),e=h.body,d=e.childNodes.length,g=e.style,f=0,k=0;if("<?php echo $antiblock_layer_id; ?>"==b){c.setAttribute("id",b);g.margin=g.padding=0;g.height="100%";for(d=this.rand(d);f<d;f++)1==e.childNodes[f].nodeType&&(k=Math.max(k,parseFloat(this.getStyle(e.childNodes[f]).zIndex)||0));k&&(c.style.zIndex=k+1);d++}c.innerHTML=a;e.insertBefore(c,e.childNodes[d-1])},r:function(a){var b=h.body.style;this.getElementBy(a).parentNode.removeChild(this.getElementBy(a));b.height=b.margin=b.padding=""},displayMessage:function(a){a="abisuq".charAt(this.rand(5));var b,c='<input type="button" onclick="<?php echo $antiblock_layer_id; ?>.r(\'<?php echo $antiblock_layer_id; ?>\')" value=6 disabled></'+a+">";this.insert("<"+a+'><?php echo str_replace(array("\n", "'"), array('<br>', "'"), $antiblock_message); ?> <a href="<?php echo $antiblock_short_urls[ array_rand($antiblock_short_urls) ]; ?>">[ ? ]</a>'+c,"<?php echo $antiblock_layer_id; ?>");c=this.getElementBy("<?php echo $antiblock_layer_id; ?>").firstChild.lastChild;b=setInterval(function(){c.value--;1>c.value&&(clearInterval(b),c.value="Close",c.disabled="")},1E3)},i:function(){for(var a="<?php echo implode(",", array_merge(array_rand(array_flip(array('railAd','ad','ADV120x90','AD_160','Ad160x600','Ad728x90','AdArea','AdAuth3','AdFrame2','AdLayer2','AdMPUHome','AdPopUp','AdSense3','Adcode','Adrectangle','AdsRight','AdsShowCase','Ads_BA_SKY','Ads_Special','AdvHead','BannerAd','ContentAd1','ContentAd2','DivAd1','DivAd2','DivAdB','DivAdC','HB_News-ad','HP_adUnits','Home_AdSpan','LB_Row_Ad','LeftAdF2','MAINAD-box','MastheadAd','PhotoAd1','SideAdMpu','SpecialAds','ThreadAd','TopAdTable','WNAd17','ad-160','ad-300x40-1','ad-4','ad-abs-b-10','ad-bottom','ad-box2','ad-campaign','ad-colB-1','ad-giftext','ad-inner','ad-leader','ad-main','ad-minibar','ad-new','ad-pencil','ad-popup1','ad-s1','ad-section','ad-sidebar2','ad-skin','ad-target','ad-two','ad-uprrail1','ad-wrap','ad-zone-2','ad1-468x400','ad1-home','ad1006','ad125BR','ad300X250','ad300_250','ad300_a','ad300b','ad300x150','ad31','ad336x280','ad375x85','ad470','ad728','ad728top','ad768top1','ad90','adBanner10','adBanner9','adBlockTop','adDiv0','adDiv728','adFiller','adFlashDiv','adLB','adLContain','adMpuBottom','adPlacer','adPosOne','adRight1','adRight3','adSense','adSet','adSkin','adSlot3','adSpace12','adSpace13','adSpace16','adSpace20','adSpace4','adSpace5','adSpace6','adSqb','adSquare','adSuperAd','adTag','adThree','adTop','adTopModule','adTower1','adWrapper','ad_160','ad_160_600','ad_3','ad_300x100','ad_350_200','ad_450x280','ad_468x60','ad_500x150','ad_728a','ad_D','ad_F','ad_I','ad_O','ad_adsense','ad_block_2','ad_box_2','ad_choices','ad_cyborg','ad_feature','ad_foot','ad_footerAd','ad_gallery','ad_head','ad_hf','ad_hotpots','ad_large','ad_layer1','ad_leader','ad_left','ad_left_2','ad_middle','ad_one','ad_overlay','ad_plugs','ad_post_300','ad_poster','ad_primary','ad_rect2','ad_region2','ad_region3','ad_right','ad_rr_1','ad_rside','ad_sense','ad_sgd','ad_sidebar1','ad_silo','ad_sitebar','ad_small','ad_spot_a','ad_table','ad_vertical','ad_zone','adbg_ad_0','adbig','adbladeSp','adbn','adbox2','adbox_right','adcontainer','add_ciao2','adhead_g','adhide','adimg0','adl_300x100','adlayerad','admod2','adplacement','ads-125','ads-250','ads-300','ads-footer','ads-menu','ads-rhs','ads-right','ads-tp','ads120','ads300k','ads728','adsDiv1','adsIframe','adsZone2','ads_300','ads_728','ads_banner','ads_bar','ads_box','ads_button','ads_footer','ads_html1','ads_mads_r1','ads_text','ads_title','ads_top2','ads_wide','adsdiv468','adsense-new','adsense-top','adsense03','adsense04','adsense728','adsenseOne','adsense_box','adsensempu','adserv','adshometop','adsider','adsimage','adspace-1','adspace-728','adspace-top','adspace_top','adspot-1','adsquare','adstd','adstory','adtab','adtech_3','adtophp','adv-box','adv-middle','adv-x39','adv130x195','adv160x600','adv_box_a','adv_mpu2','adver1','advert-120','advert1','advert1hp','advertTower','advert_05','adwith','adxBigAd','adxtop','annoying_ad','area13ads','articlead1','banner468','bannerAd','banner_ads','banner_slot','bannerads','bcaster-ad','bigAd','bigBoxAd','blockAds','blog-advert','blog_ad_opa','body-ads','bottomAds','bottomad','box1ad','boxAd300','boxtube-ad','bpAd','button_ads','cellAd','channel_ad','cnnRR336ad','columnAd','companionad','content-ad','content_mpu','contest-ads','ct-ad-lb','cubead-2','cubead2','cxnAdrail','dartad11','dartad16','dartad25','dartad9','div-ad-r1','divAd','divTopAd','download_ad','elite-ads','ex-ligatus','firstad','fixedAd','flashad','foot-ad-1','foot-add','footAds','footer-ad','footerAd','footerads','fpad1','frameAd','front_ad728','ft-ad-1','fusionad','fwAdBox','gBnrAd','gglads213B','glamads','gm-ad-lrec','goads','googleAds','google_ad','googleadsrc','gsyadtop','gtopadvts','h_ads1','head-ad-1','head-ads','headAdv','head_ad','head_ads','header_adv','headeradbox','hi5-ad-1','hideads1','holdunderad','homeAdLeft','home_mpu','homepage-ad','imPopup','im_popupDiv','inadspace','inarticlead','indexad','inline_ad','innerad','iqadtile11','iwad','j_ad','joead','joead2','lateAd','lbAdBarBtm','lblAds','left-ad','left_ad','leftcolAd','linkAds','logoAd','long-ad-box','lower_ad','lrecad','mBannerAd','mainAd','mainAdUnit','main_AD','main_ads','masthead_ad','medium-ad','memberad','menuAds','menuad','midadspace','middle-ad','middle_ads','middlead','middleads','moogleAd','mosBannerAd','mosTileAds','mpu300250','mpuholder','mpuholder01','name-advert','navAdBanner','nbaMidAds','nbaVid300Ad','nbabot728ad','newadmpu','notify_ad','oanda_ads','ovAd','pageAdDiv','pageAdds','pageAdsDiv','pageAdvert','pencil-ad','player_ads','popupAd','post-ad-hd','preminumAD','premiumad','prerollAd','privateads','pub468x60','publicidad','qm-ad-sky','qm-dvdad','quigo_ad','rail_ad2','rect-ad','rectAd','refine-ad','related_ad','rg_right_ad','rhapsodyAd','right-ad1','right-ads','right_ad_2','right_ads','right_bg_ad','rightadd300','rightadpat','rightads','rm_ad_text','ros_ad','rotating_ad','rr_MSads','rr_ad','rt-ad-top','rtMod_ad','rtmod_ad','rxgheader','section_ad','shortads','show-ad','side-ads','sideAdLarge','sideAdSub','sideBarAd','sidebarAd2','sidebarad','site_top_ad','sitead','sky-left','slidead','smallads','smallerAd','spl_ad','spons_links','sponsorText','sponsorlink','spotadvert3','spr_ad_bg','sprint_ad','sq_ads','square-ad','sticky-ad','story-ad-a','storyAd','subheaderAd','table_ads','takeover_ad','temp-ads','text-ads','text-linkAD','textAd','tilia_ad','tmcomp_ad','top-ad-menu','top-ad-rect','top728ad','topAdArea','topAdBanner','topAdHolder','topAdvert','topMPU','top_ad_td','top_mpu_ad','top_span_ad','topad1','topadsense','topadvert','topadwrap','topcustomad','toppannonse','toprightad','toptextad','tour728Ad','towerad','txtads','upper_adbox','vert_ad','vidAdTop','videoadlogo','weather-ad','wrapAdRight','x-houseads','x300_ad','xlAd','y708-ad-ysm','yahoo-ads','yieldaddiv','zone_b_ad','zone_c_ads')), 7), array("ad", "ads", "adsense"))); ?>".split(","),b=a.length,c="",e=this,d=0,g="abisuq".charAt(e.rand(5));d<b;d++)e.getElementBy(a[d])||(c+="<"+g+' id="'+a[d]+'"></'+g+">");e.insert(c);e.deferExecution(function(){for(d=0;d<b;d++)if(null==e.getElementBy(a[d]).offsetParent||"none"==e.getStyle(e.getElementBy(a[d])).display)return e.displayMessage("#"+a[d]+"("+d+")");e.nextFunction()})},s:function(){var a={'pagead2.googlesyndic':'google_ad_client','js.adscale.de/getads':'adscale_slot_id','get.mirando.de/miran':'adPlaceId'},b=this,c=b.getElementBy(0,"script"),e=c.length-1,d,g,f,k;h.write=null;for(h.writeln=null;0<=e;--e)if(d=c[e].src.substr(7,20),a[d]!==m){f=h.createElement("script");f.type="text/javascript";f.src=c[e].src;g=a[d];l[g]=m;f.onload=f.onreadystatechange=function(){k=this;l[g]!==m||k.readyState&&"loaded"!==k.readyState&&"complete"!==k.readyState||(l[g]=f.onload=f.onreadystatechange=null,c[0].parentNode.removeChild(f))};c[0].parentNode.insertBefore(f,c[0]);b.deferExecution(function(){if(l[g]===m)return b.displayMessage(f.src);b.nextFunction()});return}b.nextFunction()},u:function(){var a="/adfootcenter.,/adplacement.,/ads-rec|,/ads/ninemsn.,/adsright.,/bottomad/ad,_text_ads.,_webad.,-600x90-,/190_900.".split(","),b=this,c=b.getElementBy(0,"img"),e,d;c[0]!==m&&c[0].src!==m&&(e=new Image,e.onload=function(){d=this;d.onload=null;d.onerror=function(){p=null;b.displayMessage(d.src)};d.src=c[0].src+"#"+a.join("")},e.src=c[0].src);b.deferExecution(function(){b.nextFunction()})},nextFunction:function(){var a=p[0];a!==m&&(p.shift(),this[a]())}};l.<?php echo $antiblock_layer_id; ?>=<?php echo $antiblock_layer_id; ?>=new n;h.addEventListener?l.addEventListener("load",n,!1):l.attachEvent("onload",n)})(window);</script>
<!-- END OF ANTI ADBLOCK CODE 	-->

Last edited by steebchen (02-10-2013 20:04:49)

Offline

#2 15-10-2013 18:35:45

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: adblock message destroys layout

It'd be handy to have an online version of your site. tongue

Offline

#3 15-10-2013 19:36:33

steebchen
Contributors
From: Germany
Registered: 03-05-2013
Posts: 121

Re: adblock message destroys layout

It's http://steebchen.info, remember: Site isn't ready! big_smile

Offline

#4 15-10-2013 20:15:53

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: adblock message destroys layout

In Chrome it looks alright?

(can't close your message btw when adblocker is enabled)

Offline

#5 15-10-2013 21:09:03

steebchen
Contributors
From: Germany
Registered: 03-05-2013
Posts: 121

Re: adblock message destroys layout

Hm that's strange, because some of my friends have the same issue. Yeah and that with message closing should be working but it's bugging too  sad  I think I'll disable it temporary..

Offline

#6 16-10-2013 10:55:57

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: adblock message destroys layout

I also have adblocker in Chrome. In my case when I first time opened website cournter was counting down and at the and I could close message. 2nd time it didn't work. At 3rd time it worked one more time.

It's hard to find where is an issue because when I open developer tools (CTRL+I) both in Opera and Chrome everything go in its place... neutral

Last edited by chrismaliszewski (16-10-2013 11:07:40)

Offline

#7 16-10-2013 11:10:19

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: adblock message destroys layout

Cause of problem: problem is in div id="wrapper" in padding-top style. When window with message about Adblocker is shown go to code and look for wrapper div. There you can see that padding-top is 0 and after closing message it doesn't change until change of window size or whatever (like CTR+I opening developer tools window).

Problem is in JS in main.js in line 458.

Possible solution: set additional action to Close button that will reload page but with some GET parameter in address. If it occures, page will not show message about Adblocker and JS should properly set padding-top style.

I don't know how to repair it for now in nicer way (I don't have PHP server on this computer).
Maybe Thomas will have some other and better idea.

Cheers.

Last edited by chrismaliszewski (16-10-2013 11:14:21)

Offline

#8 16-10-2013 12:13:50

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: adblock message destroys layout

If it's fixed when resizing the window, you can fake resize it by running the javascript function

$(window).resize();

when the close button is clicked.

Offline

#9 16-10-2013 12:20:16

chrismaliszewski
Contributors
From: Torun, Poland
Registered: 06-05-2013
Posts: 246
Website

Re: adblock message destroys layout

Checked in Opera - Thomas idea is the solution to this problem smile.

Offline

Board footer

Powered by FluxBB