Unfortunately, some of the pages are now read-only, this because in the last few months some spammers decided to “contribute” to the wiki…
I'm trying to lock only the interested pages.

:!:First (semi)version of Counterize Mod available!
Please look at installation and notes for more information:!:

ATTENTION: Most of the changes presented here are for Counterize_II v 2.10
Starting from version 2.13 Counterize II will not store IPs anymore.
I would like to continue working with IPs instead of md5(IP), so I'll continue to modify version 2.12.7 (maybe if I'll have enough time I'll include also new improvements from future version of counterize…


Restore useragent filtering

Since I like to filter by useragent I restored the link for the filter

Functions modified in counterize.php

History counter: counterize_show_history

Original code:
		<td scope="col" width="20%"><small> <?php
		if ($entry->referer != "unknown")
		{
			echo "<a href=\"" . $entry->referer . "\">" . wordwrap($entry->referer, 30, "\n", 1) . "</a>";
			?> (<a
			href="edit.php?page=counterizeii/counterize.php&amp;refererfilter=<?php echo $entry->referer; ?>">F</a>)
			<?php
}
else
echo wordwrap($entry->referer, 30, "\n", 1);
?> </small></td>
		<td scope="col" style="width: 25%"><small><?php echo counterize_browser_string($entry->useragent , true, '<br />'); ?></small>
		</td>
		<td><small><?php echo $entry->keyword; ?></small></td>
Modified code:
		<td scope="col" width="20%"><small> <?php
		if ($entry->referer != "unknown")
		{
			echo "<a href=\"" . $entry->referer . "\">" . wordwrap($entry->referer, 30, "\n", 1) . "</a>";
			?> (<a
			href="edit.php?page=counterizeii/counterize.php&amp;refererfilter=<?php echo $entry->referer; ?>">F</a>)
			<?php
}
else
echo wordwrap($entry->referer, 30, "\n", 1);
?> </small></td>
		<td scope="col" style="width: 25%"><small><?php echo counterize_browser_string($entry->useragent , true, '<br />'); ?> (<a href="edit.php?page=counterizeii/counterize.php&amp;agentfilter=<?php echo $entry->useragent; ?>">F</a>)</small>
		</td>
		<td><small><?php echo $entry->keyword; ?></small></td>



History counter

Sometimes happened that I want to know how many records history is showing (for example if I'm doing a filter and the amount of data is lower that the “number of row to show” limit).
In order to obtain this I added a counter in the function “counterize_show_history” and I “echoed” it in the table.

Functions modified in counterize.php

History counter: counterize_show_history

In the explanation below I started from the results of the modification Multiple Entry Kill

Original code:
                <td scope="col" width="3%"><strong><?php _e("Kill",'counterize'); ?></strong></td></tr>
                <?php foreach($entries as $entry) { ?>
        <tr <?php if($i%2) { print "class=\"alternate\""; } ?>>
                                <td scope="col" width="6%"><small> 
								<input type="checkbox" name='counterize_killemall[<?php echo $entry->id; ?>]'
            value="<?php echo $entry->id; ?>" />
Modified code:
                <td scope="col" width="3%"><strong><?php _e("Kill",'counterize'); ?></strong></td></tr>
                <?php $entrycounter = 1;
                foreach($entries as $entry) { ?>
        <tr <?php if($i%2) { print "class=\"alternate\""; } ?>>
                                <td scope="col" width="6%"><small> <?php echo ($entrycounter."  "); $entrycounter++; ?>
								<input type="checkbox" name='counterize_killemall[<?php echo $entry->id; ?>]'
            value="<?php echo $entry->id; ?>" />



Range filter

I would like to be able to filter the records by ranges for IP, useragents and so on, and not only by the exact values.
It's not so difficult, the only thing to do is define a new parameter that can be passed by URL as did with Visits with same URL and referer not count change.

Functions modified in counterize.php

IP-Range filter: counterize_getentries

I only added another case to the list of possible arguments passed via URL that build the “main” query.
To note that I used the operator “LIKE” instead of ”=” in order to compare the pattern.

Original code:
function counterize_getentries($amount = 50, $entryID = null)
{
    $wpdb =& $GLOBALS['wpdb'];
    $sql =  'SELECT id, ip, timestamp, p.url as url, r.name as referer, ua.name as useragent, ';
    $sql .= 'm.refererID, m.agentID, m.pageID, k.keyword, k.keywordID ';
    $sql .= "FROM ".
      counterize_logTable(). " m, " .
      counterize_pageTable(). " p, " .
      counterize_agentsTable(). " ua, " .
      counterize_refererTable(). " r, " .
      counterize_keywordTable(). " k ";
    $sql .= "WHERE m.pageID = p.pageID and m.agentID = ua.agentID and m.refererID = r.refererID ";
    $sql .= " and k.keywordID = r.keywordID and ";
 
    if($_GET["ipfilter"])
      $sql .= " m.ip = '" . $_GET["ipfilter"] ."' and ";
Modified code:
function counterize_getentries($amount = 50, $entryID = null)
{
    $wpdb =& $GLOBALS['wpdb'];
    $sql =  'SELECT id, ip, timestamp, p.url as url, r.name as referer, ua.name as useragent, ';
    $sql .= 'm.refererID, m.agentID, m.pageID, k.keyword, k.keywordID ';
    $sql .= "FROM ".
      counterize_logTable(). " m, " .
      counterize_pageTable(). " p, " .
      counterize_agentsTable(). " ua, " .
      counterize_refererTable(). " r, " .
      counterize_keywordTable(). " k ";
    $sql .= "WHERE m.pageID = p.pageID and m.agentID = ua.agentID and m.refererID = r.refererID ";
    $sql .= " and k.keywordID = r.keywordID and ";
 
    if($_GET["ipfilterrange"])
      $sql .= " m.ip LIKE '" . $_GET["ipfilterrange"] ."%' and ";
    if($_GET["urifilterrange"])
      $sql .= " p.url LIKE '%" . $_GET["urifilterrange"] ."%' and ";
    if($_GET["refererfilterrange"])
      $sql .= " r.name LIKE '%" . $_GET["refererfilterrange"] ."%' and ";
    if($_GET["agentfilterrange"])
      $sql .= " ua.name LIKE '%" . $_GET["agentfilterrange"] ."%' and ";
 
    if($_GET["ipfilter"])
      $sql .= " m.ip = '" . $_GET["ipfilter"] ."' and ";



Day filter: counterize_getentries

I only added another case to the list of possible arguments passed via URL that build the “main” query.
As “original code” in the table below, I used the modified code obtained here above.

Original code:
function counterize_getentries($amount = 50, $entryID = null)
{
    $wpdb =& $GLOBALS['wpdb'];
    $sql =  'SELECT id, ip, timestamp, p.url as url, r.name as referer, ua.name as useragent, ';
    $sql .= 'm.refererID, m.agentID, m.pageID, k.keyword, k.keywordID ';
    $sql .= "FROM ".
      counterize_logTable(). " m, " .
      counterize_pageTable(). " p, " .
      counterize_agentsTable(). " ua, " .
      counterize_refererTable(). " r, " .
      counterize_keywordTable(). " k ";
    $sql .= "WHERE m.pageID = p.pageID and m.agentID = ua.agentID and m.refererID = r.refererID ";
    $sql .= " and k.keywordID = r.keywordID and ";
 
    if($_GET["ipfilterrange"])
      $sql .= " m.ip LIKE '" . $_GET["ipfilterrange"] ."%' and ";
    if($_GET["urifilterrange"])
      $sql .= " p.url LIKE '%" . $_GET["urifilterrange"] ."%' and ";
    if($_GET["refererfilterrange"])
      $sql .= " r.name LIKE '%" . $_GET["refererfilterrange"] ."%' and ";
    if($_GET["agentfilterrange"])
      $sql .= " ua.name LIKE '%" . $_GET["agentfilterrange"] ."%' and ";
 
    if($_GET["ipfilter"])
      $sql .= " m.ip = '" . $_GET["ipfilter"] ."' and ";
Modified code:
function counterize_getentries($amount = 50, $entryID = null)
{
    $wpdb =& $GLOBALS['wpdb'];
    $sql =  'SELECT id, ip, timestamp, p.url as url, r.name as referer, ua.name as useragent, ';
    $sql .= 'm.refererID, m.agentID, m.pageID, k.keyword, k.keywordID ';
    $sql .= "FROM ".
      counterize_logTable(). " m, " .
      counterize_pageTable(). " p, " .
      counterize_agentsTable(). " ua, " .
      counterize_refererTable(). " r, " .
      counterize_keywordTable(). " k ";
    $sql .= "WHERE m.pageID = p.pageID and m.agentID = ua.agentID and m.refererID = r.refererID ";
    $sql .= " and k.keywordID = r.keywordID and ";
 
    if($_GET["ipfilterrange"])
      $sql .= " m.ip LIKE '" . $_GET["ipfilterrange"] ."%' and ";
    if($_GET["urifilterrange"])
      $sql .= " p.url LIKE '%" . $_GET["urifilterrange"] ."%' and ";
    if($_GET["refererfilterrange"])
      $sql .= " r.name LIKE '%" . $_GET["refererfilterrange"] ."%' and ";
    if($_GET["agentfilterrange"])
      $sql .= " ua.name LIKE '%" . $_GET["agentfilterrange"] ."%' and ";
    if($_GET["dateday"])
      $sql .= " m.timestamp >= TIMESTAMP('" . $_GET["dateday"] ."') and m.timestamp <= TIMESTAMP('" . $_GET["dateday"] ."','24:00:00') and ";
 
    if($_GET["ipfilter"])
      $sql .= " m.ip = '" . $_GET["ipfilter"] ."' and ";



Visits with same URL and referer not counted

Partially IMPLEMENTED in Counterize II v2.11
If you are not using version 2.11 or higher, please update or take a look at revision history

In addition I setup another filter that allow to find all the visits (already in the DB) where URL and referer are exactly the same address.
In order to recall this filter is necessary to use an URL like:

http://www.yoursite.com/pathtoblog/wp-admin/edit.php?page=counterize/counterize.php&sameRefUrl=1

Functions modified in counterize.php

URL referer count: counterize_getentries

I only added another case to the list of possible arguments passed via URL that build the “main” query. Because the page URL is stored without host I used the CONCAT command and the php variable $_SERVER['HTTP_HOST'] in order “re-build” the full addresses and compare it with the referer:

Original code:
function counterize_getentries($amount = 50, $entryID = null)
{
    $wpdb =& $GLOBALS['wpdb'];
    $sql =  'SELECT id, ip, timestamp, p.url as url, r.name as referer, ua.name as useragent, ';
    $sql .= 'm.refererID, m.agentID, m.pageID, k.keyword, k.keywordID ';
    $sql .= "FROM ".
      counterize_logTable(). " m, " .
      counterize_pageTable(). " p, " .
      counterize_agentsTable(). " ua, " .
      counterize_refererTable(). " r, " .
      counterize_keywordTable(). " k ";
    $sql .= "WHERE m.pageID = p.pageID and m.agentID = ua.agentID and m.refererID = r.refererID ";
    $sql .= " and k.keywordID = r.keywordID and ";
 
    if($_GET["ipfilter"])
      $sql .= " m.ip = '" . $_GET["ipfilter"] ."' and ";
Modified code:
function counterize_getentries($amount = 50, $entryID = null)
{
    $wpdb =& $GLOBALS['wpdb'];
    $sql =  'SELECT id, ip, timestamp, p.url as url, r.name as referer, ua.name as useragent, ';
    $sql .= 'm.refererID, m.agentID, m.pageID, k.keyword, k.keywordID ';
    $sql .= "FROM ".
      counterize_logTable(). " m, " .
      counterize_pageTable(). " p, " .
      counterize_agentsTable(). " ua, " .
      counterize_refererTable(). " r, " .
      counterize_keywordTable(). " k ";
    $sql .= "WHERE m.pageID = p.pageID and m.agentID = ua.agentID and m.refererID = r.refererID ";
    $sql .= " and k.keywordID = r.keywordID and ";
 
    if($_GET["sameRefUrl"])
      $sql .= " CONCAT('".$_SERVER['HTTP_HOST']."', p.url) = r.name and ";
    if($_GET["ipfilter"])
      $sql .= " m.ip = '" . $_GET["ipfilter"] ."' and ";



Geo IP Tool

IMPLEMENTED in Counterize II v2.11
If you are not using version 2.11 or higher, please update or take a look at revision history


Multiple Entry kill

IMPLEMENTED in Counterize II v2.11
If you are not using version 2.11 or higher, please update or take a look at revision history


IP Range exclude list

New bot's useragent

A list of bot's useragent discovered by looking at the logs (in addition to the list in CII 2.12.6):

	$botarray[] = "Java/1.";
	$botarray[] = "BrowseX";
	$botarray[] = "Browsershots URL Check";
	$botarray[] = "www.searchme.com";
	$botarray[] = "Teleport Pro";
	$botarray[] = "FeedFetcher";
	$botarray[] = "Plagger";
	$botarray[] = "Java1";
	$botarray[] = "Jakarta";
	$botarray[] = "Zend_Http_Client";
	$botarray[] = "OnetSzukaj";
	$botarray[] = "DepSpid";
	$botarray[] = "Mozilla/4.0 (compatible;)";
	$botarray[] = "page-store";
        $botarray[] = "proximic";
        $botarray[] = "WordPress";
        $botarray[] = "Mozilla 2003";
        $botarray[] = "Feed::Find";
        $botarray[] = "HTMLParser";
        $botarray[] = "sds";
        $botarray[] = "W3C_CSS_Validator";
        $botarray[] = "TinEye";
        $botarray[] = "LinkAider";
        $botarray[] = "missigua";
        $botarray[] = "curl";
        $botarray[] = "htmlSQL";
        $botarray[] = "EmailSearch";

The “Mozilla/4.0 (compatible;)” seems to be a truncated UA, but I'm not sure…

New ideas

  • a way to see previous entries 1)
  • transfer the bot exclusion list from code to database Done
    • introduce an easy way to add or remove bot user agents by admin panel (see previous point). Done?
    • add a “delete entry and exclude IP” button
  • User interface for multiple filters (already possible, it's enough to add it to the URL in the address bar)
  • organization of the browser/OS statistics with a separate table for OSs and browsers names (stored as unique values and an ID in the main table as reference)
  • filter data per day (e.g. if I want to see all the entries of a particular day) I'm stupid, I'm stupid: it already exists…
  • a javascript to “confirm” the visit (something easy in order to help discriminate real-browsers from bot that usually don't use js…usually…)
  • in “history” introduce a link to Project Honey Pot (done on my version)



New ideas Under development

Discussion & suggestions

Please use the discussion page

1) to realize that I'll use the filter by date previously introduced. The “previous entries” link will bring the timestamp of the last entry in the history; instead for the “next entries” link I'll pass the timestamp of the first entry of the previous page in the URL

Tools personali