Counter + Adblock - Solutions

In case you have any problems with CrazyStat
Forum rules
Please read FAQ and search the forum before asking questions here.
Always include your CrazyStat version number.
CrazyStat documentation can be found here.

Preferred language of discussion is English so most users can profit from your threads, but German is okay as well.

Bevorzugte Sprache ist Englisch, damit möglichst viele Nutzer von den Threads profitieren können, aber Deutsch wird auch akzeptiert.
Post Reply
schmatzler
Posts: 10
Joined: Wed Mar 18, 2015 3:18 pm

Counter + Adblock - Solutions

Post by schmatzler » Wed Mar 18, 2015 3:44 pm

Adblock scripts are getting better by the minute.
A lot of the adblock subscriptions kick out CrazyStat nowadays. Their detection mechanism is fairly simple, though. They just search for "stat" in any scripts, divs or image names and block these out.

So all we have to do is to avoid anything with "stat" in the name. Some years back, I installed CrazyStat into a stat subfolder. That doesn't work well anymore. I renamed it to "zähler", which is the german word for "counting" - it doesn't get blocked (for now).

After that, I went to src/include.php and changed some bad references. Make sure to duplicate the stat.php and name it zählen.php afterwards:

Code: Select all

--- alt/include.php	2012-03-21 17:30:30.000000000 +0100
+++ neu/include.php	2015-03-18 15:38:16.180678280 +0100
@@ -63,7 +63,7 @@
  {
  $config_counter_enabled=false;
  $crazystat_add='&set_counter_enabled=false';
- $config_counter_alternative='img/blind.gif';
+ $config_counter_alternative='img/kleinbild.gif';
  $crazystat_log=file(dirname(__FILE__).'/../usr/'.$config_logfile_folder.'/'.$config_count_file);
 
  // Start reading counter value (Reload?)
@@ -155,17 +155,17 @@
  {
  if (typeof(crazystat_oldOnLoad)=='function') crazystat_oldOnLoad();
  var jetzt=new Date();
- var CrazyStatUrl='<?php echo $config_rel_path; ?>src/stat.php?<?php if($set_user) echo 'user='.$set_user.'&'; ?>breite='+screen.width+'&hoehe='+screen.height+'&colors='+screen.colorDepth+'&datei=<?php echo urlencode($_SERVER['REQUEST_URI']).'&referer='.urlencode(getenv('HTTP_REFERER')).str_replace('&','&',$crazystat_add); ?>&t='+jetzt.getTime();
- if(document.getElementById) var obj=document.getElementById('CrazyStatImage'); else if(document.all) var obj=document.all('CrazyStatImage');
+ var CrazyStatUrl='<?php echo $config_rel_path; ?>src/zählen.php?<?php if($set_user) echo 'user='.$set_user.'&'; ?>breite='+screen.width+'&hoehe='+screen.height+'&colors='+screen.colorDepth+'&datei=<?php echo urlencode($_SERVER['REQUEST_URI']).'&referer='.urlencode(getenv('HTTP_REFERER')).str_replace('&','&',$crazystat_add); ?>&t='+jetzt.getTime();
+ if(document.getElementById) var obj=document.getElementById('Zählerbild'); else if(document.all) var obj=document.all('Zählerbild');
  if(obj) { obj.src=CrazyStatUrl; obj.width=<?php echo $crazystat_breite; ?>; }
  }
 var crazystat_oldOnLoad=window.onload;
 window.onload=CrazyStat;
 /* ]]> */
 </script>
-<?php echo $crazystat_link; ?><img id="CrazyStatImage" src="<?php echo $config_rel_path; ?>src/img/blind.gif" <?php echo $crazystat_attribute; ?> width="1" /><?php if(!empty($crazystat_link)) echo '</a>';
+<?php echo $crazystat_link; ?><img id="Zählerbild" src="<?php echo $config_rel_path; ?>src/img/kleinbild.gif" <?php echo $crazystat_attribute; ?> width="1" /><?php if(!empty($crazystat_link)) echo '</a>';
 if($config_xhtml_noscript) { ?>
-<noscript><?php echo $crazystat_link; ?><img src="<?php echo $config_rel_path; ?>stat.php?datei=<?php echo urlencode($_SERVER["REQUEST_URI"])."&referer=".urlencode(getenv("HTTP_REFERER")).$crazystat_add.'&t='.$crazystat_zeit; ?>" <?php echo $crazystat_attribute.' width="'.$crazystat_breite.'"'; ?> /><?php if(!empty($crazystat_link)) echo '</a>'; ?></noscript>
+<noscript><?php echo $crazystat_link; ?><img src="<?php echo $config_rel_path; ?>zählen.php?datei=<?php echo urlencode($_SERVER["REQUEST_URI"])."&referer=".urlencode(getenv("HTTP_REFERER")).$crazystat_add.'&t='.$crazystat_zeit; ?>" <?php echo $crazystat_attribute.' width="'.$crazystat_breite.'"'; ?> /><?php if(!empty($crazystat_link)) echo '</a>'; ?></noscript>
 <?php
  } }
 else
@@ -173,7 +173,7 @@
 ?>
 //<!--
 var jetzt=new Date();
-document.write ('<?php echo $crazystat_link; ?><img src=\"<?php echo $config_rel_path; ?>src/stat.php?<?php if($set_user) echo 'user='.$set_user.'&'; ?>breite='+screen.width+'&hoehe='+screen.height+'&colors='+screen.colorDepth+'&datei=<?php echo urlencode($_SERVER["REQUEST_URI"])."&referer=".urlencode(getenv("HTTP_REFERER")).$crazystat_add.'&t='; ?>'+jetzt.getTime()+'\" alt=\"<?php echo $config_alt_text.$crazystat_c; ?>\" title=\"<?php echo $config_alt_text.$crazystat_c; ?>\"<?php echo ($crazystat_breite>0?' width="'.$crazystat_breite.'"':'').($crazystat_hoehe>0?' height="'.$crazystat_hoehe.'"':''); ?> style="border: 0;" /><?php if(!empty($crazystat_link)) echo '<\/a>'; ?>');
+document.write ('<?php echo $crazystat_link; ?><img src=\"<?php echo $config_rel_path; ?>src/zählen.php?<?php if($set_user) echo 'user='.$set_user.'&'; ?>breite='+screen.width+'&hoehe='+screen.height+'&colors='+screen.colorDepth+'&datei=<?php echo urlencode($_SERVER["REQUEST_URI"])."&referer=".urlencode(getenv("HTTP_REFERER")).$crazystat_add.'&t='; ?>'+jetzt.getTime()+'\" alt=\"<?php echo $config_alt_text.$crazystat_c; ?>\" title=\"<?php echo $config_alt_text.$crazystat_c; ?>\"<?php echo ($crazystat_breite>0?' width="'.$crazystat_breite.'"':'').($crazystat_hoehe>0?' height="'.$crazystat_hoehe.'"':''); ?> style="border: 0;" /><?php if(!empty($crazystat_link)) echo '<\/a>'; ?>');
 //-->
 </script>
-<noscript><div><?php echo $crazystat_link; ?><img src="<?php echo $config_rel_path; ?>src/stat.php?datei=<?php echo urlencode($_SERVER["REQUEST_URI"])."&referer=".urlencode(getenv("HTTP_REFERER")).$crazystat_add; ?>" alt="<?php echo $config_alt_text.$crazystat_c; ?>" title="<?php echo $config_alt_text.$crazystat_c; ?>"<?php echo ($crazystat_breite>0?' width="'.$crazystat_breite.'"':'').($crazystat_hoehe>0?' height="'.$crazystat_hoehe.'"':''); ?> style="border:0;"<?php echo ($config_xhtml_old?' /':''); ?>><?php if(!empty($crazystat_link)) echo '</a>'; ?></div></noscript><?php } echo "\n".base64_decode('PCEtLSBFTkQgQ3JhenlTdGF0IC8tLT4=')."\n"; ?>
\ No newline at end of file
+<noscript><div><?php echo $crazystat_link; ?><img src="<?php echo $config_rel_path; ?>src/zählen.php?datei=<?php echo urlencode($_SERVER["REQUEST_URI"])."&referer=".urlencode(getenv("HTTP_REFERER")).$crazystat_add; ?>" alt="<?php echo $config_alt_text.$crazystat_c; ?>" title="<?php echo $config_alt_text.$crazystat_c; ?>"<?php echo ($crazystat_breite>0?' width="'.$crazystat_breite.'"':'').($crazystat_hoehe>0?' height="'.$crazystat_hoehe.'"':''); ?> style="border:0;"<?php echo ($config_xhtml_old?' /':''); ?>><?php if(!empty($crazystat_link)) echo '</a>'; ?></div></noscript><?php } echo "\n".base64_decode('PCEtLSBFTkQgQ3JhenlTdGF0IC8tLT4=')."\n"; ?>
\ No newline at end of file
Heureka - it works! You can try it out on http://www.kawaii-blog.org in Google Chrome. Install the Adblock extension, enable all filters and you can see, that the counter still counts.
Attachments
include.patch.zip
(1.36 KiB) Downloaded 914 times

Post Reply